Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 99621b3

Browse files
author
Graham Wharton
committed
Fixed setFrom function by deprecating old and introducing new function.
1 parent c32ca7a commit 99621b3

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

lib/internal/Magento/Framework/Mail/Message.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,23 @@ public function getBody()
8989

9090
/**
9191
* {@inheritdoc}
92+
*
93+
* @deprecated This function is missing the from name. The
94+
* setFromAddress() function sets both from address and from name.
95+
* @see setFromAddress()
9296
*/
9397
public function setFrom($fromAddress)
9498
{
95-
$this->zendMessage->setFrom($fromAddress);
99+
$this->setFromAddress($fromAddress, null);
100+
return $this;
101+
}
102+
103+
/**
104+
* {@inheritdoc}
105+
*/
106+
public function setFromAddress($fromAddress, $fromName = null)
107+
{
108+
$this->zendMessage->setFrom($fromAddress, $fromName);
96109
return $this;
97110
}
98111

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function setFrom($from)
200200
public function setFromByStore($from, $store = null)
201201
{
202202
$result = $this->_senderResolver->resolve($from, $store);
203-
$this->message->setFrom($result['email'], $result['name']);
203+
$this->message->setFromAddress($result['email'], $result['name']);
204204
return $this;
205205
}
206206

lib/internal/Magento/Framework/Mail/Template/TransportBuilderByStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(
5454
public function setFromByStore($from, $store)
5555
{
5656
$result = $this->senderResolver->resolve($from, $store);
57-
$this->message->setFrom($result['email'], $result['name']);
57+
$this->message->setFromAddress($result['email'], $result['name']);
5858

5959
return $this;
6060
}

lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderByStoreTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function testSetFromByStore()
5555
->with($sender, $store)
5656
->willReturn($sender);
5757
$this->messageMock->expects($this->once())
58-
->method('setFrom')
59-
->with('[email protected]', 'name')
58+
->method('setFromAddress')
59+
->with($sender['email'], $sender['name'])
6060
->willReturnSelf();
6161

6262
$this->model->setFromByStore($sender, $store);

lib/internal/Magento/Framework/Mail/Test/Unit/Template/TransportBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public function testSetFromByStore()
176176
->with($sender, $store)
177177
->willReturn($sender);
178178
$this->messageMock->expects($this->once())
179-
->method('setFrom')
180-
->with('[email protected]', 'name')
179+
->method('setFromAddress')
180+
->with($sender['email'], $sender['name'])
181181
->willReturnSelf();
182182

183183
$this->builder->setFromByStore($sender, $store);

0 commit comments

Comments
 (0)