Closed bmellink closed 4 years ago
It would be great to allow adding a friendly name for the from address, in a way like this:
$m->setFrom('user@example.com', 'John Doe');
I implemented this by adding the following changes in SimpleEmailServiceMessage.php:
SimpleEmailServiceMessage.php
public function setFrom($from, $fromname='') { $this->from = $from; $this->fromname = $fromname; // added statement $this->is_clean = false; return $this; }
Then in SimpleEmailService.php I made a change in the function sendEmail() by changing the line:
SimpleEmailService.php
function sendEmail()
$ses_request->setParameter('Source', $sesMessage->encodeRecipients($sesMessage->from));
into:
if ($sesMessage->fromname) $ses_request->setParameter('Source', '"'.$sesMessage->fromname.'" <'.$sesMessage->from.'>'); else $ses_request->setParameter('Source', $sesMessage->encodeRecipients($sesMessage->from));
For this to work in raw email mode the same change needs to be made to getRawMessage();
getRawMessage();
if ($this->fromname) $raw_message .= 'From: "' . $this->fromname . '" <' . $this->from . '>' . "\n"; else $raw_message .= 'From: ' . $this->encodeRecipients($this->from) . "\n";
Can you please add these changes to the master? (or implement the same functionality differently).
Hi @bmellink , you can use this functionality with the following format:
$m->addTo('Recipient Name <recipient@example.com>'); $m->setFrom('Sender <user@example.com>');
It would be great to allow adding a friendly name for the from address, in a way like this:
$m->setFrom('user@example.com', 'John Doe');
I implemented this by adding the following changes in
SimpleEmailServiceMessage.php
:Then in
SimpleEmailService.php
I made a change in thefunction sendEmail()
by changing the line:into:
For this to work in raw email mode the same change needs to be made to
getRawMessage();
Can you please add these changes to the master? (or implement the same functionality differently).