Browse Source

MailUtils : essais delivery receipt

feature/module_traiteur_v1
Guillaume 4 years ago
parent
commit
a6acc32c9d
1 changed files with 14 additions and 5 deletions
  1. +14
    -5
      ShopBundle/Services/MailUtils.php

+ 14
- 5
ShopBundle/Services/MailUtils.php View File

const ATTACHMENT_DATA = 'attachment-data'; const ATTACHMENT_DATA = 'attachment-data';
const ATTACHMENT_FILENAME = 'attachment-filename'; const ATTACHMENT_FILENAME = 'attachment-filename';
const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type'; const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type';
//const DISPOSITION_NOTIFICATION_TO = 'disposition-notification-to' ;


protected $transport; protected $transport;
protected $templating; protected $templating;
->setBody($this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData), 'text/html') ->setBody($this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData), 'text/html')
->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData)); ->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData));


if (isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
if(isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
$message->addCc($params[self::COPY_TO]); $message->addCc($params[self::COPY_TO]);
} }


if (isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
if(isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
$message->addBcc($params[self::COPY_HIDDEN_TO]); $message->addBcc($params[self::COPY_HIDDEN_TO]);
} }



if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
if(isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
$message->addReplyTo($params[self::REPLY_TO]); $message->addReplyTo($params[self::REPLY_TO]);
} }


if (isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) {
if(isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) {
$message->attach(\Swift_Attachment::newInstance( $message->attach(\Swift_Attachment::newInstance(
$params[self::ATTACHMENT_DATA], $params[self::ATTACHMENT_DATA],
$params[self::ATTACHMENT_FILENAME], $params[self::ATTACHMENT_FILENAME],
)); ));
} }


/*if(isset($params[self::DISPOSITION_NOTIFICATION_TO]) && $params[self::DISPOSITION_NOTIFICATION_TO]) {
$emailFromDispositionNotificationTo = $emailFrom ;
if(isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
$emailFromDispositionNotificationTo = $params[self::REPLY_TO] ;
}
$message->getHeaders()->addTextHeader('Disposition-Notification-To', $emailFromDispositionNotificationTo) ;
$message->getHeaders()->addMailboxHeader('Disposition-Notification-To', $emailFromDispositionNotificationTo);
}*/

$this->transport->send($message); $this->transport->send($message);
} }
} }

Loading…
Cancel
Save