Tuesday, February 1, 2022

[FIXED] Laravel Send Mail with Yahoo SMTP: Swift_TransportException Expected response code 250

Issue

I wanna to send mail with Yahoo SMTP service but return error in Laravel 5.5:

Expected response code 250 but got code "550", with message "550 Request failed; Mailbox unavailable "

Before that I tested send mail with Gmail SMTP service, every things is ok, but about Yahoo I have problem. My .env configuration is:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=587
MAIL_USERNAME=example@yahoo.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=tls

I send mail with this code:

public function sendMail(){
        $data = []; // Empty array
        Mail::send('welcome', $data, function($message)
        {
            $message->to('john.doe@outlook.com', 'John Doe')->subject('Welcome!');
        });
        return 'ok';
    }

Even I active SMTP from Yahoo mail configuration:

enter image description here

What should I do?


Solution

MAIL_FROM_ADDRESS is required and the value is just equal to MAIL_USERNAME.

Your .env should be like this:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mail.yahoo.com
MAIL_PORT=587
MAIL_FROM_ADDRESS=example@yahoo.com
MAIL_USERNAME=example@yahoo.com
MAIL_PASSWORD=*****
MAIL_ENCRYPTION=tls

This solves the problem.



Answered By - Carlette

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.