コード例 #1
0
 /**
  * {@inheritdoc}
  */
 function buildNewsletterMail(array &$message, MailInterface $mail)
 {
     // Get message data from the mail.
     $message['headers'] = $mail->getHeaders($message['headers']);
     $message['subject'] = $mail->getSubject();
     $message['body']['body'] = $mail->getBody();
     $message['body']['footer'] = $mail->getFooter();
     if ($mail->getFormat() == 'html') {
         // Set the necessary headers to detect this as an HTML mail. Set both the
         // Content-Type header, and the format (Swiftmailer) and plain (Mime Mail)
         // params.
         $message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
         $message['params']['format'] = 'text/html';
         $message['params']['plain'] = NULL;
         // Provide a plain text version, both in params][plaintext (Mime Mail) and
         // plain (Swiftmailer).
         $message['params']['plaintext'] = $mail->getPlainBody() . "\n" . $mail->getPlainFooter();
         $message['plain'] = $message['params']['plaintext'];
         // Add attachments, again, both for the attachments key (Mime Mail) and
         // files (Swiftmailer).
         $message['params']['attachments'] = $mail->getAttachments();
         $message['params']['files'] = $message['params']['attachments'];
     } else {
         // This is a plain text email, explicitly mark it as such, the default
         // Content-Type header already defaults to that.
         $message['params']['plain'] = TRUE;
         $message['params']['format'] = 'text/plain';
     }
 }