function simple_mail_send in Simple Mail 8
Same name and namespace in other branches
- 7 simple_mail.module \simple_mail_send()
- 2.0.x simple_mail.module \simple_mail_send()
Easy-to-use email sending function.
Parameters
(string) $from: Email sender. Defaults to the system email.
(string) $to: Email receipient.
(string) $subject: Email subject.
(string) $body: Email message body (can be HTML or plaintext).
Return value
(array) Message array structure, as returned by drupal_mail(). Check for 'result' = TRUE to verify that the message was sent (at least, according to PHP).
1 call to simple_mail_send()
- SimpleMailSendQueuedMail::processItem in src/
Plugin/ QueueWorker/ SimpleMailSendQueuedMail.php - Works on a single queue item.
File
- ./
simple_mail.module, line 59 - Simple Mail module.
Code
function simple_mail_send($from, $to, $subject, $body) {
if (empty($from)) {
$from = \Drupal::config('system.site')
->get('mail');
}
$params['subject'] = $subject;
$params['body'] = $body;
$langcode = \Drupal::languageManager()
->getDefaultLanguage();
// Send email with drupal_mail.
return \Drupal::service('plugin.manager.mail')
->mail('simple_mail', 'simple_mail', $to, $langcode, $params, $from);
}