电子邮件错误
AbstractSmtpTransport.php第383行中的Swift_TransportException: 预期的响应代码250,但得到代码“530”,消息“530 5.7.1认证需要 “ 到目前为止这是我的mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => 'hello@example.com',
'name' => 'Example',
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
];
这是我的控制器
public function contactstore(Request $request)
{
$data = array_map('trim', $request->all());
$rules = [
'email' => 'required | email',
'name' => 'required',
'msg' => 'required | min:8',
];
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput()->with('error', 'Validation Error.');
}
else {
$data = [
'from' => 'quizmumbai@gmail.com',
'name' => $data['name'],
'email' => $data['email'],
'msg' => $data['msg'],
'view_name' => 'pages.email.querymail',
'to' => 'yogesh696ksingh@gmail.com',
'subject' => 'Event Query for TML 2017',
'timestamp' => date('j/M/Y', time()),
];
Mail::send($data['view_name'], $data, function ($message) use ($data) {
$message->from($data['from'], $data['name']);
$message->to($data['to'])->subject($data['subject']);
});
if (count(Mail::failures()) > 0) {
return redirect()->back()->with('error', 'Cannot send mail');
}
else return redirect()->back()->with('success', 'We will get back to you shortly')->with('message','Thanks for');
}
}
是因为我正在尝试使用本地服务器吗?
答案 0 :(得分:0)
您必须重新启动网络服务器才能获取新的.env
值。