【发布时间】:2015-11-21 14:06:36
【问题描述】:
我正在使用 laravel 5.1,我正在尝试从本地主机的 laravel 应用程序发送电子邮件。
我已经在 .env 文件中配置了我的电子邮件凭据但是,我收到 Authentication required 错误。 我附上了 .env 文件和控制器文件的代码。
.env
APP_ENV=local
APP_DEBUG=true
APP_KEY=1MJzLfnALmtppcbfzoVtlf8rzsFX94nm
DB_HOST=localhost
DB_DATABASE=real_estate
DB_USERNAME=root
DB_PASSWORD=''
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=my_account@gmail.com
MAIL_PASSWORD=my_password
MAIL_ENCRYPTION=ssl
控制器代码
$subject = 'Welcome!';
Mail::send('mail', ['key' => 'value'], function($message) use ($subject) {
// note: if you don't set this, it will use the defaults from config/mail.php
$message->from('my_account@gmail.com', 'Sender Name');
$message->to('receiver_account@gmail.com', 'John Smith')
->subject($subject);
});
【问题讨论】:
标签: php email smtp laravel-5.1