Search code examples
phpemaillaravel-5smtpyahoo-mail

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


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
[email protected]
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('[email protected]', '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
    [email protected]
    [email protected]
    MAIL_PASSWORD=*****
    MAIL_ENCRYPTION=tls
    

    This solves the problem.