Skip to content

Commit

Permalink
SparkPost add Reply-To
Browse files Browse the repository at this point in the history
  • Loading branch information
sousekmfcc committed Mar 20, 2018
1 parent 2107459 commit 5bc9f7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/Adapter/SparkPost/SparkPostAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MassimoFilippi\MailModule\Exception\RuntimeException;
use MassimoFilippi\MailModule\Model\Message\MessageInterface;
use MassimoFilippi\MailModule\Model\Message\SparkPostMessage;
use MassimoFilippi\MailModule\Model\ReplyTo\ReplyTo;
use SparkPost\SparkPost;

/**
Expand Down Expand Up @@ -87,6 +88,17 @@ public function sendMail(MessageInterface $message)
unset($recipient);
}

if(false && $message->hasReplyTo()) {
/** @var ReplyTo $replyTo */
$replyTo = current($message->getReplyTo());

if(!empty($replyTo->getName())) {
$payload['content']['reply_to'] = $replyTo->getName() . ' <'. $replyTo->getEmail() .'>';
} else {
$payload['content']['reply_to'] = $replyTo->getEmail();
}
}

if ($message instanceof SparkPostMessage) {

if ($message->isTemplate()) {
Expand Down
6 changes: 1 addition & 5 deletions src/Adapter/SparkPost/SparkPostSmtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ public function sendMail(MessageInterface $message)
/** @var ReplyTo $replyTo */
$replyTo = current($message->getReplyTo());

if(!empty($replyTo->getName())) {
$payload['content']['reply_to'] = $replyTo->getName() . ' <'. $replyTo->getEmail() .'>';
} else {
$payload['content']['reply_to'] = $replyTo->getEmail();
}
$zendMessage->setReplyTo($replyTo->getEmail(), !empty($replyTo->getName()) ? $replyTo->getName() : null);
}

$zendMessage->setSubject($message->getSubject());
Expand Down

0 comments on commit 5bc9f7d

Please sign in to comment.