我正在尝试使用我的Gmail帐户发送邮件,但它不起作用。
Connection could not be established with host smtp.gmail.com [Connection timed out #110]
.env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=jitendrameena38@gmail.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=ssl
和mail.php是 -
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'jitendrameena38@gmail.com', 'name' => "Minmarks"],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
并在我的控制器中 -
Mail::raw('This is an test e-mail', function ($message) {
$message->to("jitu@gmail.com", "someone");
$message->subject("hi checking");
$message->getSwiftMessage();
});
这里缺少什么。请帮忙。 感谢。
答案 0 :(得分:0)
你应该设置
MAIL_DRIVER=sendmail
它对我有用。