Laravel SMTP Email

Get started with Laravel 4.2 I tried to send an email using the Gmail STMP server. Below is my application /config/mail.php.

return array(
    'driver' => 'smtp',
    'host' => 'smtp.gmail.com',
    'port' => 465,
    'from' => array('address' => 'sample_address@gmail.com', 'name' => 'Sample'),
    'encryption' => 'tls',
    'username' => 'sample_address@gmail.com',
    'password' => 'sample password',
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,
);

Below is my PHP code.

<!-- app/views/emails/welcome.php -->
Mail::send('emails.welcome', 'Laravel Admin', function($msg) {
   $msg->from('sample_address@gmail.com', 'Laravel Admin');
   $msg->to('sample_receiver@gmail.com');
});

But that will not work. I have already configured my XAMPP php.ini on my OSX MAC. It only works when sending regular PHP mail, not SMTP. The error message I received from Laravel on the watch page is " Error in the exception handler ." I would like to see more error information, but I do not know how to get additional information. What is wrong with my code? What else do I need to do or customize? Thank!

+4
source share
3

Input::merge(array('email'=>'sample_receiver@gmail.com','name'=>'sample_name')); 

Mail::send('emails.welcome', 'Laravel Admin', function($msg) {
   $msg->from('sample_address@gmail.com', 'Laravel Admin');
   $msg->to(Input::get('email'), Input::get('name'))->subject('You have');
});

""

return array(
    'driver' => 'smtp',
    'host' => 'smtp.gmail.com',
    'port' => 465,
    'from' => array('address' => 'sample_address@gmail.com', 'name' => 'Sample'),
    'encryption' => 'ssl',
    'username' => 'sample_address@gmail.com',
    'password' => 'sample password',
    'sendmail' => '/usr/sbin/sendmail -bs',
    'pretend' => false,
);
+6

"" ssl, gmail IMAP config

+1

gmail, . .

gmail, : https://accounts.google.com/b/0/DisplayUnlockCaptcha

"". , . Google .

0

Source: https://habr.com/ru/post/1548168/


All Articles