コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function sendMail(MailInterface $mail)
 {
     $params['simplenews_mail'] = $mail;
     // Send mail.
     $message = $this->mailManager->mail('simplenews', $mail->getKey(), $mail->getRecipient(), $mail->getLanguage(), $params, $mail->getFromFormatted());
     // Log sent result in watchdog.
     if ($this->config->get('mail.debug')) {
         if ($message['result']) {
             $this->logger->debug('Outgoing email. Message type: %type<br />Subject: %subject<br />Recipient: %to', array('%type' => $mail->getKey(), '%to' => $message['to'], '%subject' => $message['subject']));
         } else {
             $this->logger->error('Outgoing email failed. Message type: %type<br />Subject: %subject<br />Recipient: %to', array('%type' => $mail->getKey(), '%to' => $message['to'], '%subject' => $message['subject']));
         }
     }
     // Build array of sent results for spool table and reporting.
     if ($message['result']) {
         $result = array('status' => SpoolStorageInterface::STATUS_DONE, 'error' => FALSE);
     } else {
         // This error may be caused by faulty mailserver configuration or overload.
         // Mark "pending" to keep trying.
         $result = array('status' => SpoolStorageInterface::STATUS_PENDING, 'error' => TRUE);
     }
     return $result;
 }