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

Set Store hostname in SmtpOptions #415

Open
wants to merge 1 commit into
base: 2.4
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions Mail/Rse/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace Mageplaza\Smtp\Mail\Rse;

use Magento\Store\Model\StoreManagerInterface;
use Mageplaza\Smtp\Helper\Data;
use Laminas\Mail\Message;
use Laminas\Mail\Transport\Smtp;
Expand All @@ -38,6 +39,11 @@ class Mail
*/
protected $smtpHelper;

/**
* @var StoreManagerInterface
*/
protected $_storeManager;

/**
* @var array Is module enable by store
*/
Expand Down Expand Up @@ -82,10 +88,12 @@ class Mail
* Mail constructor.
*
* @param Data $helper
* @param StoreManagerInterface $storeManager
*/
public function __construct(Data $helper)
public function __construct(Data $helper, StoreManagerInterface $storeManager)
{
$this->smtpHelper = $helper;
$this->_storeManager = $storeManager;
}

/**
Expand Down Expand Up @@ -168,7 +176,8 @@ public function getTransport($storeId)
unset($options['ssl']);
}
unset($options['type']);

$options['name'] = parse_url($this->_storeManager->getStore()->getBaseUrl(), PHP_URL_HOST);

$options = new SmtpOptions($options);

$this->_transport = new Smtp($options);
Expand Down