我能够从 xampp (Mecury) localhost 向 localhost 发送电子邮件。但是当我尝试从 Gmail 向本地主机发送电子邮件时,我无法做到这一点。
我们的主要目的是从 Gmail 帐户向本地主机发送电子邮件。我该怎么做,任何帮助都将不胜感激。
这是我的app.php文件中的代码:
'EmailTransport' => [
'default' => [
//'className' => MailTransport::class,
'className' => 'Smtp',
/*
* The following keys are used in SMTP transports:
*/
'host' => 'smtp.gmail.com',
'port' => 587,
'timeout' => 30,
'username' => 'my@gmail.com',
'password' => 'secret',
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => ['demotest@localhost.com' => 'demotest'],
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
],
],