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

Commit 7ec263b

Browse files
committed
Add possibility to define from_name and to_name
1 parent f1be7db commit 7ec263b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/MailSender.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function send($name, array $context = [])
2929
$template = $this->twig->loadTemplate($name);
3030

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

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

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

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

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

0 commit comments

Comments
 (0)