Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Add possibility to define from_name and to_name
Browse files Browse the repository at this point in the history
  • Loading branch information
jvasseur committed Oct 1, 2015
1 parent f1be7db commit 7ec263b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function send($name, array $context = [])
$template = $this->twig->loadTemplate($name);

$blocks = [];
foreach (['from', 'to', 'subject', 'body_txt', 'body_html'] as $blockName) {
foreach (['from', 'from_name', 'to', 'to_name', 'subject', 'body_txt', 'body_html'] as $blockName) {
$rendered = $this->renderBlock($template, $blockName, $context);

if ($rendered) {
Expand All @@ -41,10 +41,10 @@ public function send($name, array $context = [])

$mail = new \Swift_Message();
$mail->setSubject($blocks['subject']);
$mail->setFrom($blocks['from']);
$mail->setFrom(isset($blocks['from_name']) ? [$blocks['from'] => $blocks['from_name']] : $blocks['from']);

if (isset($blocks['to'])) {
$mail->setTo($blocks['to']);
$mail->setTo(isset($blocks['to_name']) ? [$blocks['to'] => $blocks['to_name']] : $blocks['to']);
}

if (isset($blocks['body_txt']) && isset($blocks['body_html'])) {
Expand Down

0 comments on commit 7ec263b

Please sign in to comment.