Laravel 5 邮件不工作 Swift_RfcComplianceException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30029469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5 mail not working Swift_RfcComplianceException
提问by xenish
I am new to using laravel 5 and trying to send mail but I am getting the following. error: Swift_RfcComplianceException in MailboxHeader.php line 348:
Address in mailbox given [Kathmandu-Nepal] does not comply with RFC 2822, 3.6.2.
我是使用 laravel 5 并尝试发送邮件的新手,但我收到以下信息。错误:Swift_RfcComplianceException in MailboxHeader.php line 348:
Address in mailbox given [Kathmandu-Nepal] does not comply with RFC 2822, 3.6.2.
My code for the controller is
我的控制器代码是
<?php namespace App\Http\Controllers\BackEnd;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Input;
use Illuminate\Http\Request;
use Mail;
class MailController extends Controller {
/**
* Sends Mail.
*
* @return Response
*/
public function sendMail()
{
$user = Input::all();
Mail::send('emails.simpleMail', $user, function($message)
{
$message->to(Input::get('emailto'))->subject('Simple Mail!');
});
}
}
回答by markkkk
I had the same problem and the problem was that i have an invalid emailaddress in the mail configuration in \app\config\mail.php. So please check your configuration.
我遇到了同样的问题,问题是我在 \app\config\mail.php 的邮件配置中有一个无效的电子邮件地址。所以请检查您的配置。
in my case the configuration contains something like:
在我的情况下,配置包含以下内容:
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => 'null', 'name' => 'Your Name'],
i fixed it by setting a valid email address:
我通过设置一个有效的电子邮件地址来修复它:
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => ['address' => '[email protected]', 'name' => 'Your name'],