Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDVA-275: Emails from admin being sent out using default config’s ema… #13124

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/code/Magento/Checkout/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'one
'items' => nl2br($items),
'total' => $total,
]
)->setScopeId(
$checkout->getStoreId()
)->setFrom(
$this->scopeConfig->getValue(
'checkout/payment_failed/identity',
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public function testSendPaymentFailedEmail()
$this->returnSelf()
);

$this->_transportBuilder->expects($this->once())->method('setScopeId')->will($this->returnSelf());
$this->_transportBuilder->expects($this->once())->method('addBcc')->will($this->returnSelf());
$this->_transportBuilder->expects(
$this->once()
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ protected function sendEmailTemplate(

$transport = $this->transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(
['area' => Area::AREA_FRONTEND, 'store' => $storeId]
)->setTemplateVars($templateParams)->setFrom(
)->setTemplateVars($templateParams)->setScopeId($storeId)->setFrom(
$this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId)
)->addTo($email, $this->customerViewHelper->getCustomerName($customer))->getTransport();

Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ protected function _sendEmailTemplate($template, $sender, $templateParams = [],
['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId]
)->setTemplateVars(
$templateParams
)->setScopeId(
$storeId
)->setFrom(
$this->_scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId)
)->addTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,9 @@ public function testSendPasswordReminderEmail()
->method('setTemplateVars')
->with(['customer' => $this->customerSecure, 'store' => $this->store])
->willReturnSelf();
$this->transportBuilder->expects($this->once())
->method('setScopeId')
->willReturnSelf();
$this->transportBuilder->expects($this->once())
->method('setFrom')
->with($sender)
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function testSendNewAccountEmailWithoutStoreId()
'setTemplateIdentifier',
'setTemplateOptions',
'setTemplateVars',
'setScopeId',
'setFrom',
'addTo',
];
Expand Down
6 changes: 6 additions & 0 deletions app/code/Magento/Newsletter/Model/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@ public function sendConfirmationRequestEmail()
]
)->setTemplateVars(
['subscriber' => $this, 'store' => $this->_storeManager->getStore()]
)->setScopeId(
$this->_storeManager->getStore()->getId()
)->setFrom(
$this->_scopeConfig->getValue(
self::XML_PATH_CONFIRM_EMAIL_IDENTITY,
Expand Down Expand Up @@ -742,6 +744,8 @@ public function sendConfirmationSuccessEmail()
]
)->setTemplateVars(
['subscriber' => $this]
)->setScopeId(
$this->_storeManager->getStore()->getId()
)->setFrom(
$this->_scopeConfig->getValue(
self::XML_PATH_SUCCESS_EMAIL_IDENTITY,
Expand Down Expand Up @@ -794,6 +798,8 @@ public function sendUnsubscriptionEmail()
]
)->setTemplateVars(
['subscriber' => $this]
)->setScopeId(
$this->_storeManager->getStore()->getId()
)->setFrom(
$this->_scopeConfig->getValue(
self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY,
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/ProductAlert/Model/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ public function send()
'customerName' => $this->_customerHelper->getCustomerName($this->_customer),
'alertGrid' => $alertGrid,
]
)->setScopeId(
$storeId
)->setFrom(
$this->_scopeConfig->getValue(
self::XML_PATH_EMAIL_IDENTITY,
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Wishlist/Controller/Index/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public function execute()
'message' => $message,
'store' => $this->storeManager->getStore(),
]
)->setScopeId(
$this->storeManager->getStore()->getStoreId()
)->setFrom(
$this->scopeConfig->getValue(
'wishlist/email/email_identity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public function testExecute()
['wishlist/email/email_identity', ScopeInterface::SCOPE_STORE, null, $from],
]);

$this->store->expects($this->once())
$this->store->expects($this->exactly(2))
->method('getStoreId')
->willReturn($storeId);

Expand Down Expand Up @@ -663,6 +663,9 @@ public function testExecute()
'store' => $this->store,
])
->willReturnSelf();
$this->transportBuilder->expects($this->once())
->method('setScopeId')
->willReturnSelf();
$this->transportBuilder->expects($this->once())
->method('setFrom')
->with($from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class TransportBuilder
*/
protected $mailTransportFactory;

/** @var int|null */
private $scopeId;

/**
* @param FactoryInterface $templateFactory
* @param MessageInterface $message
Expand Down Expand Up @@ -158,6 +161,18 @@ public function setReplyTo($email, $name = null)
return $this;
}

/**
* Set scope
*
* @param int $scopeId
* @return $this
*/
public function setScopeId($scopeId)
{
$this->scopeId = $scopeId;
return $this;
}

/**
* Set mail from address
*
Expand All @@ -166,7 +181,7 @@ public function setReplyTo($email, $name = null)
*/
public function setFrom($from)
{
$result = $this->_senderResolver->resolve($from);
$result = $this->_senderResolver->resolve($from, $this->scopeId);
$this->message->setFrom($result['email'], $result['name']);
return $this;
}
Expand Down Expand Up @@ -244,6 +259,7 @@ protected function reset()
$this->templateIdentifier = null;
$this->templateVars = null;
$this->templateOptions = null;
$this->scopeId = null;
return $this;
}

Expand Down