试图使Laravel 5电子邮件正常工作 [英] Trying to get Laravel 5 email to work
问题描述
我正在尝试通过输入URL向指定用户发送电子邮件,但是出现以下错误:
I'm trying to send an email to a specified user by typing in the URL, but I'm getting the following error:
AbstractSmtpTransport.php第383行中的Swift_TransportException: 预期的响应代码为250,但得到的代码为"530",消息为"530 5.7.1" 需要验证
Swift_TransportException in AbstractSmtpTransport.php line 383: Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
到目前为止,我只是试图使其与Gmail一起使用.我怎样才能使它正常工作?
So far I'm just trying to get it to work with Gmail. How can I get this to work?
这是我到目前为止的内容: mail.php
This is what I have so far: mail.php
<?php
return [
'driver' => env('MAIL_DRIVER',' smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' =>"MyUsername@gmail.com" , 'name' => "example"],
'encryption' => 'tls',
'username' => env('MyUsername@gmail.com'),
'password' => env('MyPassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
这是我在路线上所拥有的:
This is what I have in the routes:
Route::get('test', function() {
Mail::send('Email.test', [], function ($message) {
$message->to('example@gmail.com', 'HisName')->subject('Welcome!');
});
});
这就是我的控制器中的内容:
This is what I have in my controller:
class MailController extends Controller
{
public function Sending_Email()
{
$this->call('GET','Email.test');
return View('Email.test');
}
}
这是我的.env文件中的内容:
And this is what is in my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MyUsername@gmail.com
MAIL_PASSWORD=MyPassword
推荐答案
我知道它现在正在为您工作@ Vantheman6,但这对我有用,以防与其他人相同.
I know it's working for you now @Vantheman6 but this is what worked for me in case it's the same for someone else.
我在我的.env文件中添加了我正在使用的邮件服务的详细信息.因此,请确保以下详细信息
I added to my .env file the details of the mail service I am using. So make sure the following details
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MyUsername@gmail.com
MAIL_PASSWORD=MyPassword
.env文件中的
正确.
in the .env file are accurate.
注意:不要忘记在编辑.env文件后重新启动服务器,这样它将选择您放入其中的新数据.
如果不重新启动服务器,即使您进行了可能导致此错误的更改,.env文件仍将继续向应用程序显示旧邮件数据.
If you don't restart your server, the .env file will still continue to present the old mail data to the app even though you have made changes which can cause this error.
这篇关于试图使Laravel 5电子邮件正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!