-function securemail_settings_post(App &$a, array &$b){
-
- if (!local_user()) {
- return;
- }
-
- if ($_POST['securemail-submit']) {
- PConfig::set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
- $enable = ((x($_POST, 'securemail-enable')) ? 1 : 0);
- PConfig::set(local_user(), 'securemail', 'enable', $enable);
- info(t('Secure Mail Settings saved.') . EOL);
-
- if ($_POST['securemail-submit'] == t('Save and send test')) {
- $sitename = $a->config['sitename'];
-
- $hostname = $a->get_hostname();
- if (strpos($hostname, ':')) {
- $hostname = substr($hostname, 0, strpos($hostname, ':'));
- }
-
- $sender_email = $a->config['sender_email'];
- if (empty($sender_email)) {
- $sender_email = 'noreply@' . $hostname;
- }
-
- $subject = 'Friendica - Secure Mail - Test';
- $message = 'This is a test message from your Friendica Secure Mail addon.';
-
- $params = array(
- 'uid' => local_user(),
- 'fromName' => $sitename,
- 'fromEmail' => $sender_email,
- 'toEmail' => $a->user['email'],
- 'messageSubject' => $subject,
- 'htmlVersion' => "<p>{$message}</p>",
- 'textVersion' => $message,
- );
-
- // enable addon for test
- PConfig::set(local_user(), 'securemail', 'enable', 1);
-
- $res = Emailer::send($params);
-
- // revert to saved value
- PConfig::set(local_user(), 'securemail', 'enable', $enable);
-
- if ($res) {
- info(t('Test email sent') . EOL);
- } else {
- notice(t('There was an error sending the test email') . EOL);
- }
- }
- }
+function securemail_settings_post(App &$a, array &$b)
+{
+ if (!local_user()) {
+ return;
+ }
+
+ if ($_POST['securemail-submit']) {
+ DI::pConfig()->set(local_user(), 'securemail', 'pkey', trim($_POST['securemail-pkey']));
+ $enable = (!empty($_POST['securemail-enable']) ? 1 : 0);
+ DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable);
+ info(DI::l10n()->t('Secure Mail Settings saved.') . EOL);
+
+ if ($_POST['securemail-submit'] == DI::l10n()->t('Save and send test')) {
+
+ $res = DI::emailer()->send(new SecureTestEmail(DI::app(), DI::config(), DI::pConfig(), DI::baseUrl()));
+
+ // revert to saved value
+ DI::pConfig()->set(local_user(), 'securemail', 'enable', $enable);
+
+ if ($res) {
+ info(DI::l10n()->t('Test email sent') . EOL);
+ } else {
+ notice(DI::l10n()->t('There was an error sending the test email') . EOL);
+ }
+ }
+ }