Laravel 5 邮件不工作 Swift_RfcComplianceException
Laravel 5 mail not working Swift_RfcComplianceException
我刚开始使用 laravel 5 并尝试发送邮件,但我收到以下信息。错误:Swift_RfcComplianceException in MailboxHeader.php line 348:
Address in mailbox given [Kathmandu-Nepal] does not comply with RFC 2822, 3.6.2.
我的控制器代码是
<?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!');
});
}
}
我遇到了同样的问题,问题是我在 \app\config\mail.php 的邮件配置中有一个无效的电子邮件地址。所以请检查你的配置。
在我的例子中,配置包含如下内容:
/*
|--------------------------------------------------------------------------
| 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'],
我通过设置有效的电子邮件地址修复了它:
/*
|--------------------------------------------------------------------------
| 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' => 'me@example.com', 'name' => 'Your name'],
我刚开始使用 laravel 5 并尝试发送邮件,但我收到以下信息。错误:Swift_RfcComplianceException in MailboxHeader.php line 348:
Address in mailbox given [Kathmandu-Nepal] does not comply with RFC 2822, 3.6.2.
我的控制器代码是
<?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!');
});
}
}
我遇到了同样的问题,问题是我在 \app\config\mail.php 的邮件配置中有一个无效的电子邮件地址。所以请检查你的配置。
在我的例子中,配置包含如下内容:
/*
|--------------------------------------------------------------------------
| 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'],
我通过设置有效的电子邮件地址修复了它:
/*
|--------------------------------------------------------------------------
| 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' => 'me@example.com', 'name' => 'Your name'],