Issue #2572597 by alexpott, bircher: Replace !placeholder with @placeholder in mail code
parent
a9b2470f6f
commit
96843822c9
|
@ -53,7 +53,8 @@ interface MailInterface {
|
||||||
* - User <user@example.com>
|
* - User <user@example.com>
|
||||||
* - User <user@example.com>, Another User <anotheruser@example.com>
|
* - User <user@example.com>, Another User <anotheruser@example.com>
|
||||||
* - subject: Subject of the email to be sent. This must not contain any
|
* - subject: Subject of the email to be sent. This must not contain any
|
||||||
* newline characters, or the mail may not be sent properly.
|
* newline characters, or the mail may not be sent properly. The subject
|
||||||
|
* is converted to plain text by the mail plugin manager.
|
||||||
* - body: Message to be sent. Accepts both CRLF and LF line-endings.
|
* - body: Message to be sent. Accepts both CRLF and LF line-endings.
|
||||||
* Email bodies must be wrapped. For smart plain text wrapping you can use
|
* Email bodies must be wrapped. For smart plain text wrapping you can use
|
||||||
* \Drupal\Core\Mail\MailFormatHelper::wrapMail() .
|
* \Drupal\Core\Mail\MailFormatHelper::wrapMail() .
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace Drupal\Core\Mail;
|
namespace Drupal\Core\Mail;
|
||||||
|
|
||||||
|
use Drupal\Component\Utility\PlainTextOutput;
|
||||||
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
|
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
|
||||||
use Drupal\Core\Plugin\DefaultPluginManager;
|
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||||
use Drupal\Core\Cache\CacheBackendInterface;
|
use Drupal\Core\Cache\CacheBackendInterface;
|
||||||
|
@ -222,6 +223,12 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface {
|
||||||
}
|
}
|
||||||
// Sending was originally requested and was not canceled.
|
// Sending was originally requested and was not canceled.
|
||||||
else {
|
else {
|
||||||
|
// Ensure that subject is plain text. By default translated and
|
||||||
|
// formatted strings are prepared for the HTML context and email
|
||||||
|
// subjects are plain strings.
|
||||||
|
if ($message['subject']) {
|
||||||
|
$message['subject'] = PlainTextOutput::renderFromHtml($message['subject']);
|
||||||
|
}
|
||||||
$message['result'] = $system->mail($message);
|
$message['result'] = $system->mail($message);
|
||||||
// Log errors.
|
// Log errors.
|
||||||
if (!$message['result']) {
|
if (!$message['result']) {
|
||||||
|
|
|
@ -67,8 +67,8 @@ interface MailManagerInterface extends PluginManagerInterface {
|
||||||
* $message['send'] = FALSE;
|
* $message['send'] = FALSE;
|
||||||
* break;
|
* break;
|
||||||
* }
|
* }
|
||||||
* $message['subject'] = t('Notification from !site', $variables, $options);
|
* $message['subject'] = t('Notification from @site', $variables, $options);
|
||||||
* $message['body'][] = t("Dear !username\n\nThere is new content available on the site.", $variables, $options);
|
* $message['body'][] = t("Dear @username\n\nThere is new content available on the site.", $variables, $options);
|
||||||
* break;
|
* break;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
|
|
@ -35,6 +35,7 @@ class PhpMail implements MailInterface {
|
||||||
public function format(array $message) {
|
public function format(array $message) {
|
||||||
// Join the body array into one string.
|
// Join the body array into one string.
|
||||||
$message['body'] = implode("\n\n", $message['body']);
|
$message['body'] = implode("\n\n", $message['body']);
|
||||||
|
|
||||||
// Convert any HTML to plain-text.
|
// Convert any HTML to plain-text.
|
||||||
$message['body'] = MailFormatHelper::htmlToText($message['body']);
|
$message['body'] = MailFormatHelper::htmlToText($message['body']);
|
||||||
// Wrap the mail body for sending.
|
// Wrap the mail body for sending.
|
||||||
|
|
|
@ -122,17 +122,17 @@ function contact_mail($key, &$message, $params) {
|
||||||
$language = \Drupal::languageManager()->getLanguage($message['langcode']);
|
$language = \Drupal::languageManager()->getLanguage($message['langcode']);
|
||||||
|
|
||||||
$variables = array(
|
$variables = array(
|
||||||
'!site-name' => \Drupal::config('system.site')->get('name'),
|
'@site-name' => \Drupal::config('system.site')->get('name'),
|
||||||
'!subject' => $contact_message->getSubject(),
|
'@subject' => $contact_message->getSubject(),
|
||||||
'!form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL,
|
'@form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL,
|
||||||
'!form-url' => \Drupal::url('<current>', [], ['absolute' => TRUE, 'language' => $language]),
|
'@form-url' => \Drupal::url('<current>', [], ['absolute' => TRUE, 'language' => $language]),
|
||||||
'!sender-name' => $sender->getDisplayName(),
|
'@sender-name' => $sender->getDisplayName(),
|
||||||
);
|
);
|
||||||
if ($sender->isAuthenticated()) {
|
if ($sender->isAuthenticated()) {
|
||||||
$variables['!sender-url'] = $sender->url('canonical', array('absolute' => TRUE, 'language' => $language));
|
$variables['@sender-url'] = $sender->url('canonical', array('absolute' => TRUE, 'language' => $language));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$variables['!sender-url'] = $params['sender']->getEmail();
|
$variables['@sender-url'] = $params['sender']->getEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array('langcode' => $language->getId());
|
$options = array('langcode' => $language->getId());
|
||||||
|
@ -140,27 +140,27 @@ function contact_mail($key, &$message, $params) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'page_mail':
|
case 'page_mail':
|
||||||
case 'page_copy':
|
case 'page_copy':
|
||||||
$message['subject'] .= t('[!form] !subject', $variables, $options);
|
$message['subject'] .= t('[@form] @subject', $variables, $options);
|
||||||
$message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, $options);
|
$message['body'][] = t("@sender-name (@sender-url) sent a message using the contact form at @form-url.", $variables, $options);
|
||||||
$build = entity_view($contact_message, 'mail', $language->getId());
|
$build = entity_view($contact_message, 'mail', $language->getId());
|
||||||
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
|
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'page_autoreply':
|
case 'page_autoreply':
|
||||||
$message['subject'] .= t('[!form] !subject', $variables, $options);
|
$message['subject'] .= t('[@form] @subject', $variables, $options);
|
||||||
$message['body'][] = $params['contact_form']->getReply();
|
$message['body'][] = $params['contact_form']->getReply();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'user_mail':
|
case 'user_mail':
|
||||||
case 'user_copy':
|
case 'user_copy':
|
||||||
$variables += array(
|
$variables += array(
|
||||||
'!recipient-name' => $params['recipient']->getDisplayName(),
|
'@recipient-name' => $params['recipient']->getDisplayName(),
|
||||||
'!recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)),
|
'@recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)),
|
||||||
);
|
);
|
||||||
$message['subject'] .= t('[!site-name] !subject', $variables, $options);
|
$message['subject'] .= t('[@site-name] @subject', $variables, $options);
|
||||||
$message['body'][] = t('Hello !recipient-name,', $variables, $options);
|
$message['body'][] = t('Hello @recipient-name,', $variables, $options);
|
||||||
$message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form at !site-name.", $variables, $options);
|
$message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options);
|
||||||
$message['body'][] = t("If you don't want to receive such emails, you can change your settings at !recipient-edit-url.", $variables, $options);
|
$message['body'][] = t("If you don't want to receive such emails, you can change your settings at @recipient-edit-url.", $variables, $options);
|
||||||
$build = entity_view($contact_message, 'mail', $language->getId());
|
$build = entity_view($contact_message, 'mail', $language->getId());
|
||||||
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
|
$message['body'][] = (string) \Drupal::service('renderer')->renderPlain($build);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -91,7 +91,7 @@ class MailHandler implements MailHandlerInterface {
|
||||||
|
|
||||||
// For the email message, clarify that the sender name is not verified; it
|
// For the email message, clarify that the sender name is not verified; it
|
||||||
// could potentially clash with a username on this site.
|
// could potentially clash with a username on this site.
|
||||||
$sender_cloned->name = $this->t('!name (not verified)', array('!name' => $message->getSenderName()));
|
$sender_cloned->name = $this->t('@name (not verified)', array('@name' => $message->getSenderName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build email parameters.
|
// Build email parameters.
|
||||||
|
|
|
@ -446,7 +446,7 @@ function update_fetch_data_finished($success, $results) {
|
||||||
function update_mail($key, &$message, $params) {
|
function update_mail($key, &$message, $params) {
|
||||||
$langcode = $message['langcode'];
|
$langcode = $message['langcode'];
|
||||||
$language = \Drupal::languageManager()->getLanguage($langcode);
|
$language = \Drupal::languageManager()->getLanguage($langcode);
|
||||||
$message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => \Drupal::config('system.site')->get('name')), array('langcode' => $langcode));
|
$message['subject'] .= t('New release(s) available for @site_name', array('@site_name' => \Drupal::config('system.site')->get('name')), array('langcode' => $langcode));
|
||||||
foreach ($params as $msg_type => $msg_reason) {
|
foreach ($params as $msg_type => $msg_reason) {
|
||||||
$message['body'][] = _update_message_text($msg_type, $msg_reason, $langcode);
|
$message['body'][] = _update_message_text($msg_type, $msg_reason, $langcode);
|
||||||
}
|
}
|
||||||
|
@ -456,10 +456,10 @@ function update_mail($key, &$message, $params) {
|
||||||
}
|
}
|
||||||
$settings_url = \Drupal::url('update.settings', [], ['absolute' => TRUE]);
|
$settings_url = \Drupal::url('update.settings', [], ['absolute' => TRUE]);
|
||||||
if (\Drupal::config('update.settings')->get('notification.threshold') == 'all') {
|
if (\Drupal::config('update.settings')->get('notification.threshold') == 'all') {
|
||||||
$message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, !url.', array('!url' => $settings_url));
|
$message['body'][] = t('Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, @url.', array('@url' => $settings_url));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$message['body'][] = t('Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, !url.', array('!url' => $settings_url));
|
$message['body'][] = t('Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, @url.', array('@url' => $settings_url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,9 +628,9 @@ function update_verify_update_archive($project, $archive_file, $directory) {
|
||||||
elseif (!$compatible_project) {
|
elseif (!$compatible_project) {
|
||||||
$errors[] = \Drupal::translation()->formatPlural(
|
$errors[] = \Drupal::translation()->formatPlural(
|
||||||
count($incompatible),
|
count($incompatible),
|
||||||
'%archive_file contains a version of %names that is not compatible with Drupal !version.',
|
'%archive_file contains a version of %names that is not compatible with Drupal @version.',
|
||||||
'%archive_file contains versions of modules or themes that are not compatible with Drupal !version: %names',
|
'%archive_file contains versions of modules or themes that are not compatible with Drupal @version: %names',
|
||||||
array('!version' => \Drupal::CORE_COMPATIBILITY, '%archive_file' => drupal_basename($archive_file), '%names' => implode(', ', $incompatible))
|
array('@version' => \Drupal::CORE_COMPATIBILITY, '%archive_file' => drupal_basename($archive_file), '%names' => implode(', ', $incompatible))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue