[Mime] Keep Sender full address when used by non-SMTP transports
This commit is contained in:
parent
05fe56b88e
commit
1ca9be77aa
@ -44,9 +44,13 @@ class Envelope
|
|||||||
|
|
||||||
public function setSender(Address $sender): void
|
public function setSender(Address $sender): void
|
||||||
{
|
{
|
||||||
$this->sender = new Address($sender->getAddress());
|
$this->sender = $sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Address Returns a "mailbox" as specified by RFC 2822
|
||||||
|
* Must be converted to an "addr-spec" when used as a "MAIL FROM" value in SMTP (use getAddress())
|
||||||
|
*/
|
||||||
public function getSender(): Address
|
public function getSender(): Address
|
||||||
{
|
{
|
||||||
return $this->sender;
|
return $this->sender;
|
||||||
|
@ -29,8 +29,8 @@ class EnvelopeTest extends TestCase
|
|||||||
|
|
||||||
public function testConstructorWithNamedAddressSender()
|
public function testConstructorWithNamedAddressSender()
|
||||||
{
|
{
|
||||||
$e = new Envelope(new Address('fabien@symfony.com', 'Fabien'), [new Address('thomas@symfony.com')]);
|
$e = new Envelope($sender = new Address('fabien@symfony.com', 'Fabien'), [new Address('thomas@symfony.com')]);
|
||||||
$this->assertEquals(new Address('fabien@symfony.com'), $e->getSender());
|
$this->assertEquals($sender, $e->getSender());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructorWithAddressRecipients()
|
public function testConstructorWithAddressRecipients()
|
||||||
@ -54,31 +54,31 @@ class EnvelopeTest extends TestCase
|
|||||||
public function testSenderFromHeaders()
|
public function testSenderFromHeaders()
|
||||||
{
|
{
|
||||||
$headers = new Headers();
|
$headers = new Headers();
|
||||||
$headers->addPathHeader('Return-Path', new Address('return@symfony.com', 'return'));
|
$headers->addPathHeader('Return-Path', $return = new Address('return@symfony.com', 'return'));
|
||||||
$headers->addMailboxListHeader('To', ['from@symfony.com']);
|
$headers->addMailboxListHeader('To', ['to@symfony.com']);
|
||||||
$e = Envelope::create(new Message($headers));
|
$e = Envelope::create(new Message($headers));
|
||||||
$this->assertEquals(new Address('return@symfony.com', 'return'), $e->getSender());
|
$this->assertEquals($return, $e->getSender());
|
||||||
|
|
||||||
$headers = new Headers();
|
$headers = new Headers();
|
||||||
$headers->addMailboxHeader('Sender', new Address('sender@symfony.com', 'sender'));
|
$headers->addMailboxHeader('Sender', $sender = new Address('sender@symfony.com', 'sender'));
|
||||||
$headers->addMailboxListHeader('To', ['from@symfony.com']);
|
$headers->addMailboxListHeader('To', ['to@symfony.com']);
|
||||||
$e = Envelope::create(new Message($headers));
|
$e = Envelope::create(new Message($headers));
|
||||||
$this->assertEquals(new Address('sender@symfony.com', 'sender'), $e->getSender());
|
$this->assertEquals($sender, $e->getSender());
|
||||||
|
|
||||||
$headers = new Headers();
|
$headers = new Headers();
|
||||||
$headers->addMailboxListHeader('From', [new Address('from@symfony.com', 'from'), 'some@symfony.com']);
|
$headers->addMailboxListHeader('From', [$from = new Address('from@symfony.com', 'from'), 'some@symfony.com']);
|
||||||
$headers->addMailboxListHeader('To', ['from@symfony.com']);
|
$headers->addMailboxListHeader('To', ['to@symfony.com']);
|
||||||
$e = Envelope::create(new Message($headers));
|
$e = Envelope::create(new Message($headers));
|
||||||
$this->assertEquals(new Address('from@symfony.com', 'from'), $e->getSender());
|
$this->assertEquals($from, $e->getSender());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSenderFromHeadersWithoutFrom()
|
public function testSenderFromHeadersWithoutFrom()
|
||||||
{
|
{
|
||||||
$headers = new Headers();
|
$headers = new Headers();
|
||||||
$headers->addMailboxListHeader('To', ['from@symfony.com']);
|
$headers->addMailboxListHeader('To', ['to@symfony.com']);
|
||||||
$e = Envelope::create($message = new Message($headers));
|
$e = Envelope::create($message = new Message($headers));
|
||||||
$message->getHeaders()->addMailboxListHeader('From', [new Address('from@symfony.com', 'from')]);
|
$message->getHeaders()->addMailboxListHeader('From', [$from = new Address('from@symfony.com', 'from')]);
|
||||||
$this->assertEquals(new Address('from@symfony.com', 'from'), $e->getSender());
|
$this->assertEquals($from, $e->getSender());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRecipientsFromHeaders()
|
public function testRecipientsFromHeaders()
|
||||||
|
Reference in New Issue
Block a user