简体   繁体   中英

How to send email using Laravel 5.2?

Here is my Route.php

Route::get('invitations' , 'Invitationscontroller@accept');

Below is my Invitationscontroller.php

public function accept(){

        $email_id =  Users::select('email_id')->get();

        Mail::send('test' , array('user' => $email_id) , function ($message){

            $message -> to('xyzabc@gmail.com' ) -> subject ('Welcome!!!');
        });
        return "Success";
    }

I have configured mail.php as per requirements stated in tutorial.

When I run the URL, I get the error as

Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
"

Where m I missing something?

Thank you.

As the error message clearly says, you have a problem with the authentication towards your mail providers SMTP.

You need to configure your mail settings in your .env file, see sample data:

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Please check that you entered valid data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM