Skip to content
Snippets Groups Projects
Commit 7ed5bb59 authored by Miroslav Lee's avatar Miroslav Lee
Browse files

phpmailer.3.x-dev.rector

parent 950f2aff
No related branches found
No related tags found
No related merge requests found
......@@ -85,7 +85,7 @@ function mimemail_phpmailer_send($message) {
return $mail->SmtpSend($header, $message['body']);
}
catch (phpmailerException $e) {
drupal_set_message(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', ['@error' => $e->getMessage()]), 'error');
\Drupal::messenger()->addError(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', ['@error' => $e->getMessage()]));
\Drupal::logger('phpmailer')->error($e->getMessage());
return FALSE;
}
......
......@@ -3,4 +3,5 @@ description: Integrates the PHPMailer library for SMTP e-mail delivery.
type: module
package: Mail
core: 8.x
core_version_requirement: ^8 || ^9
configure: phpmailer.settings
......@@ -53,7 +53,7 @@ function phpmailer_install() {
*/
// if (!phpmailer_active() && !(\Drupal::moduleHandler()->moduleExists('mimemail') && variable_get('mimemail_engine', 'mimemail') == 'phpmailer')) {
if (!phpmailer_active()) {
drupal_set_message(t('PHPMailer has been installed, but it is not currently active. Activate and configure it by navigating to Configuration > System > PHPMailer (/admin/config/system/phpmailer).'));
\Drupal::messenger()->addStatus(t('PHPMailer has been installed, but it is not currently active. Activate and configure it by navigating to Configuration > System > PHPMailer (/admin/config/system/phpmailer).'));
}
// if (\Drupal::moduleHandler()->moduleExists('mailsystem')) {
......@@ -93,7 +93,7 @@ function phpmailer_uninstall() {
\Drupal::configFactory()->getEditable('phpmailer.settings')
->clear('smtp_on')
->save();
drupal_set_message(t('PHPMailer has been disabled.'));
\Drupal::messenger()->addStatus(t('PHPMailer has been disabled.'));
}
/**
......
<?php
use Drupal\Core\Link;
/**
* @file
* Integrates the PHPMailer library for SMTP e-mail delivery.
......@@ -22,14 +23,14 @@ function phpmailer_form_mimemail_admin_settings_alter(&$form, &$form_state) {
$mimemail_alter = &$form['mimemail']['mimemail_alter'];
$mimemail_alter['#disabled'] = TRUE;
$mimemail_alter['#default_value'] = 0;
$phpmailer_settings = \Drupal::l(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
$phpmailer_settings = Link::fromTextAndUrl(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
$mimemail_alter['#description'] = t('PHPMailer has been set to deliver all site messages. To let Mime Mail apply styles and formatting to system e-mails but still use PHPMailer for mail transport, uncheck <em>Use PHPMailer to send e-mails</em> first on the @url. Then activate this setting and choose PHPMailer from the list of e-mail engines below.', ['@url' => $phpmailer_settings]);
}
// @todo Move to MimeMail project.
/**
* @todo This needs to be figured out.
*/
$phpmailer_preview = \Drupal::l(t('preview of a styled e-mail'), Url::fromRoute('phpmailer/preview'));
$phpmailer_preview = Link::fromTextAndUrl(t('preview of a styled e-mail'), Url::fromRoute('phpmailer/preview'));
$form['preview'] = [
'#type' => 'item',
'#title' => t('Preview'),
......@@ -56,7 +57,7 @@ function phpmailer_mailengine($op, $message = []) {
];
case 'settings':
$phpmailer_settings = \Drupal::l(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
$phpmailer_settings = Link::fromTextAndUrl(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
$form['info']['#markup'] = t('To configure your mail server settings, visit the @url.', ['@url' => $phpmailer_settings]);
return $form;
......
......@@ -2,6 +2,7 @@
namespace Drupal\phpmailer\Form;
use Drupal\Core\Link;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
......@@ -90,7 +91,7 @@ class SettingsForm extends ConfigFormBase {
// }
// elseif (!$config->get('smtp_on') && empty($form_state['input'])) {
if (!$config->get('smtp_on') && empty($form_state->input)) {
drupal_set_message(t('PHPMailer is currently disabled.'), 'warning');
$this->messenger()->addWarning(t('PHPMailer is currently disabled.'));
}
$form['server']['smtp_host'] = [
......@@ -282,7 +283,7 @@ class SettingsForm extends ConfigFormBase {
$mail_config->set('interface.default', $mail_system)->save();
}
drupal_set_message(t('PHPMailer will be used to deliver all site e-mails.'));
$this->messenger()->addStatus(t('PHPMailer will be used to deliver all site e-mails.'));
\Drupal::logger('phpmailer')->notice('PHPMailer has been enabled.');
}
}
......@@ -299,7 +300,7 @@ class SettingsForm extends ConfigFormBase {
$mail_config->set('interface.default', $mail_system)->save();
}
drupal_set_message(t('PHPMailer has been disabled.'));
$this->messenger()->addStatus(t('PHPMailer has been disabled.'));
\Drupal::logger('phpmailer')->notice('PHPMailer has been disabled.');
}
......@@ -349,8 +350,8 @@ class SettingsForm extends ConfigFormBase {
$ret_val = phpmailer_send($message);
}
$watchdog_url = Url::fromRoute('dblog.overview');
$watchdog_url = \Drupal::l(t('Check the logs'), $watchdog_url);
drupal_set_message(t('A test e-mail has been sent to %email. @watchdog-url for any error messages.', [
$watchdog_url = Link::fromTextAndUrl(t('Check the logs'), $watchdog_url);
$this->messenger()->addStatus(t('A test e-mail has been sent to %email. @watchdog-url for any error messages.', [
'%email' => $values['phpmailer_test'],
'@watchdog-url' => $watchdog_url,
]));
......
......@@ -125,7 +125,7 @@ class DrupalPHPMailer extends PHPMailer implements MailInterface {
if ($this->SMTPDebug) {
if ($this->drupalDebug && ($this->drupalDebugOutput = ob_get_contents())) {
drupal_set_message($this->drupalDebugOutput);
\Drupal::messenger()->addStatus($this->drupalDebugOutput);
if (\Drupal::config('phpmailer.settings')->get('smtp_debug_log', 0)) {
\Drupal::logger('phpmailer')->debug('Output of communication with SMTP server:<br /><pre>{output}</pre>', ['output' => print_r($this->drupalDebugOutput, TRUE)]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment