【问题标题】:Laravel 5 mail not working Swift_RfcComplianceExceptionLaravel 5 邮件无法正常工作 Swift_RfcComplianceException
【发布时间】:2015-05-04 11:52:41
【问题描述】:

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

}

【问题讨论】:

  • 错误告诉您问题出在哪里:“Kathmandu-Nepal”不是电子邮件地址。您可能会用表单中的位置覆盖电子邮件地址(通过使用相同的输入名称,例如)

标签: php laravel laravel-5 swiftmailer


【解决方案1】:

我遇到了同样的问题,问题是我在 \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'],

【讨论】:

  • @surajmishra 也许您的脚本中其他地方没有 rfc 2822 兼容电子邮件地址?例如,在您的收件人地址中?
猜你喜欢
  • 1970-01-01
  • 2015-07-05
  • 2015-07-28
  • 1970-01-01
  • 2015-12-03
  • 1970-01-01
  • 2013-11-09
  • 2017-06-25
  • 1970-01-01
相关资源
最近更新 更多