Laravel 5邮件不起作用Swift_RfcComplianceException

xen*_*ish 1 php swiftmailer laravel laravel-5

我是使用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!');
        });
    }

}
Run Code Online (Sandbox Code Playgroud)

mar*_*kkk 5

我有同样的问题,问题是我在\ app \ config \ mail.php的邮件配置中有无效的emailaddress。因此,请检查您的配置。

就我而言,配置包含以下内容:

/*
|--------------------------------------------------------------------------
| 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'],
Run Code Online (Sandbox Code Playgroud)

我通过设置有效的电子邮件地址来修复它:

/*
|--------------------------------------------------------------------------
| 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'],
Run Code Online (Sandbox Code Playgroud)