M
M
Mark2021-06-09 16:14:35
Yii
Mark, 2021-06-09 16:14:35

How to send email using another server in Yii2?

There is a domain.com domain, which is hosted on server No. 1. I'm trying to send an email, but through another domain - anotherdomain.com, which is hosted on server #2 .

I am getting an error:

Expected response code 354 but got code "503", with message "503-All RCPT commands were rejected with this error:
503-Temporary local problem - please try later
503 Valid RCPT command must precede DATA
"


I read that the error is due to the fact that the actual sending from server No. 1 of the domain.com domain, but it is necessary from domain No. 2 to anotherdomain.com.

How can I get around this and send mail using another server?
Configurations (example):
'mailer' => [
  'class' => Mailer::class,
  'viewPath' => '@common/mail',
  'useFileTransport' => false,
  'messageConfig' => [
    'charset' => 'UTF-8',
    'from' => ['[email protected]' => 'SiteName'],
  ],
  'transport' => [
    'class' => 'Swift_SmtpTransport',
    'host' => 'anotherdomain.loc',
    'username' => '[email protected]',
    'password' => 'somePassword95X',
    #'port' => '465',
  ]
],

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question