我正在尝试通过键入URL向指定用户发送电子邮件,但是我收到以下错误:
AbstractSmtpTransport.php第383行中的Swift_TransportException:预期响应代码250但得到代码"530",消息"530 5.7.1需要验证
到目前为止,我只是想让它与Gmail一起使用.我怎样才能让它发挥作用?
这是我到目前为止: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,
];
Run Code Online (Sandbox Code Playgroud)
这就是我在路线中所拥有的:
Route::get('test', function() {
Mail::send('Email.test', [], function ($message) {
$message->to('example@gmail.com', 'HisName')->subject('Welcome!');
});
});
Run Code Online (Sandbox Code Playgroud)
这就是我在我的控制器中所拥有的:
class MailController extends Controller
{
public function Sending_Email()
{
$this->call('GET','Email.test');
return View('Email.test');
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我的.env文件中的内容:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MyUsername@gmail.com
MAIL_PASSWORD=MyPassword
Run Code Online (Sandbox Code Playgroud) 好吧,让我首先开始说我对laravel 5很新.我一直在google上搜索只是通过输入相应的URL而没有运气来发送一封简单的电子邮件.不幸的是,我发现那里的文档并没有那么有用,只是给出了一个广泛的外观(我理解laravel 5是新的,但仍然令人沮丧哈哈).对于我正在尝试做的事情没有任何幻想,我只是想在我做其他任何事情之前将其付诸实践.我现在正试图使用gmail来解决这个问题,但是一旦我解决了这个问题,我当然会尝试像Mailgun这样的东西.这是我现在的代码第一个是在mail.php中:
return [
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
'driver' => env('smtp'),
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of …Run Code Online (Sandbox Code Playgroud)