Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from stefliekens/reply-to
Browse files Browse the repository at this point in the history
Added Reply-To address
  • Loading branch information
veewee authored Aug 29, 2016
2 parents 2073eba + 146c352 commit 4e0df78
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 3 deletions.
2 changes: 2 additions & 0 deletions spec/Phpro/MailManager/Adapter/MandrillAdapterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function it_should_send_a_mail_with_mandrill_template($transport)
&& $message->getCc()->has('[email protected]')
&& $message->getBcc()->has('[email protected]')
&& $message->getFrom()->has('[email protected]')
&& $message->getReplyTo()->has('[email protected]')
&& $message->getSubject() == $mail->getSubject()
&& $message->getOptions() == ['subaccount' => 'test']
&& $message->getGlobalMetadata() == ['meta1' => 'meta1']
Expand Down Expand Up @@ -67,6 +68,7 @@ public function it_should_send_a_mail_with_zend_view_renderer($transport, $messa
&& $message->getCc()->has('[email protected]')
&& $message->getBcc()->has('[email protected]')
&& $message->getFrom()->has('[email protected]')
&& $message->getReplyTo()->has('[email protected]')
&& $message->getSubject() == $mail->getSubject()
&& $message->getOptions() == ['subaccount' => 'test']
&& $message->getImages() == []
Expand Down
1 change: 1 addition & 0 deletions spec/Phpro/MailManager/Adapter/ZendMailAdapterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function it_should_send_a_mail($transport, $messageCreator, $mailMessage)
&& $message->getCc()->has('[email protected]')
&& $message->getBcc()->has('[email protected]')
&& $message->getFrom()->has('[email protected]')
&& $message->getReplyTo()->has('[email protected]')
&& $message->getSubject() == $mail->getSubject();
}))->shouldBeCalled();

Expand Down
15 changes: 13 additions & 2 deletions spec/Phpro/MailManager/Mail/Base/MailSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ public function it_should_provide_a_from_addresses()
$result->shouldHaveCount(1);
}

public function it_should_provide_a_reply_to_address()
{
$this->setReplyTo('[email protected]', 'name');
$this->getReplyTo()['[email protected]']->shouldBe('name');

$this->setReplyTo('[email protected]');
$result = $this->getReplyTo();
$result[0]->shouldBe('[email protected]');
$result->shouldHaveCount(1);
}

public function it_should_provide_a_subject()
{
$value = 'subject';
Expand All @@ -76,12 +87,12 @@ public function it_should_provide_attachments()
}

/**
* @param Zend\Mail\Header\HeaderInterface $header
* @param \Zend\Mail\Header\HeaderInterface $header
*/
public function it_should_provide_headers($header)
{
$header->getFieldName()->willReturn('Reply-To');
$header->getFieldValue()->willReturn('[email protected]');
$header->getFieldValue(false)->willReturn('[email protected]');

$this->addHeader($header);
$this->addHeaders(['Content-Type' => 'text/html']);
Expand Down
1 change: 1 addition & 0 deletions src/Phpro/MailManager/Adapter/MandrillAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected function createMessage(MandrillInterface $mail)
$message->setTo($mail->getTo());
$message->setCc($mail->getCc());
$message->setBcc($mail->getBcc());
$message->setReplyTo($mail->getReplyTo());

if ($mail->getFrom()) {
$message->setFrom($mail->getFrom());
Expand Down
1 change: 1 addition & 0 deletions src/Phpro/MailManager/Adapter/ZendMailAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected function createMessage(ZendMailInterface $mail)
$message->setCc($mail->getCc());
$message->setBcc($mail->getBcc());
$message->setFrom($mail->getFrom());
$message->setReplyTo($mail->getReplyTo());
$message->setSubject($mail->getSubject());
$message->setBody($this->messageCreator->createMessage($mail));

Expand Down
29 changes: 28 additions & 1 deletion src/Phpro/MailManager/Mail/Base/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class Mail
*/
protected $from = [];

/**
* @var array
*/
protected $replyTo = [];

/**
* @var string
*/
Expand Down Expand Up @@ -125,13 +130,35 @@ public function setFrom($email, $name = null)
}

/**
* @return string
* @return array
*/
public function getFrom()
{
return $this->from;
}

/**
* @param $email
* @param null $name
*/
public function setReplyTo($email, $name = null)
{
$this->replyTo = [];
if ($name) {
$this->replyTo[$email] = $name;
return;
}
$this->replyTo[] = $email;
}

/**
* @return array
*/
public function getReplyTo()
{
return $this->replyTo;
}

/**
* @param array $params
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Phpro/MailManager/Mail/MailInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public function getSubject();
* @return array
*/
public function getTo();

/**
* @return array
*/
public function getReplyTo();
}
1 change: 1 addition & 0 deletions stub/Phpro/MailManager/Mail/ProvidesMandrillStubSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected function createEmptyMailStub()
$mail->getCc()->willReturn(['[email protected]' => 'me']);
$mail->getBcc()->willReturn(['[email protected]' => 'me']);
$mail->getFrom()->willReturn(['[email protected]' => 'me']);
$mail->getReplyTo()->willReturn(['[email protected]' => 'me']);
$mail->getSubject()->willReturn('Subject');

$mail->getHeaders()->willReturn($headers);
Expand Down
1 change: 1 addition & 0 deletions stub/Phpro/MailManager/Mail/ProvidesZendMailStubSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected function getMailStub()
$mail->getCc()->willReturn(['[email protected]' => 'me']);
$mail->getBcc()->willReturn(['[email protected]' => 'me']);
$mail->getFrom()->willReturn(['[email protected]' => 'me']);
$mail->getReplyTo()->willReturn(['[email protected]' => 'me']);
$mail->getSubject()->willReturn('Subject');

$mail->getParams()->willReturn(['param1' => 'value1']);
Expand Down

0 comments on commit 4e0df78

Please sign in to comment.