A
A
Artem Prokhorov2022-03-08 21:05:14
PHP
Artem Prokhorov, 2022-03-08 21:05:14

How to send a letter using mailer, from the mail I need?

Config:

"mailer" : {
        "class" : "yii\\swiftmailer\\Mailer",
        "useFileTransport": false,
        "transport": {
            "class" : "Swift_SmtpTransport",
            "host"  : "smtp.yandex.ru",
            "username": "mail1",
            "password": "somepassword",
            "port"  : "465",
            "encryption" : "ssl"
        }
    }

Departure:
Yii::$app->mailer->compose()
            ->setFrom('mail2')
            ->setTo('reciver')
            ->setSubject('Тема сообщения')
            ->setTextBody('Текст сообщения')
            ->send();

Mistake:
"Expected response code 250 but got code "553", with message "553 5.7.1 Sender address rejected: not owned by auth user.


I want to send a letter from mail2 to the receiver, and use mail1 cleanly so that smpt can be used.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yakov, 2022-03-08
Svetsky @jamessvetsky

As far as I can see, mail1 does not pass authorization, most likely you need to either enable the portal password in the settings (they called it that usual) or use application passwords.
6227aa4a31f74817391392.jpeg
But in general, a very bad option. On the one hand, Yandex can block sending via its SMTP, I wrote more in this article
https://7fk.ru/nastroyka-smtp/
On the other hand, sending via mail1 with the from mail2 field will be perceived by all mailers as spoofing and letters will not get everywhere even in the spam folder

F
FanatPHP, 2022-03-08
@FanatPHP

Well, if you yourself can’t guess in any way, then I’ll tell you: set the password for this mail in the settings.
You can't thank

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question