Laravel邮件无法发送邮件

时间:2014-09-24 09:50:33

标签: php email laravel swiftmailer

所以我第一次尝试Laravel邮件程序,但是我遇到了一些问题,而正常的php mail()只是发送了邮件。

我的laravel代码:

if(Mail::send('pages/mail', $data, function($message)
{
    $message->from('webmaster@example.com', Input::get('name'));

    $message->to('nobody@example.com')->subject('Welcome to My Laravel app!');
}))
{
    return "success";
}
else
{
    return Mail::failures();
}

我的laravel错误响应:

"["nobody@example.com"]"

(基本上是我放在to()的邮件地址。

如果我使用正常的php mail(),它会毫无错误地发送邮件(它只会进入我的垃圾邮件文件夹,但这只是一个测试)。

知道问题可能是什么?

1 个答案:

答案 0 :(得分:5)

确保您在config/mail.php中使用了正确的邮件驱动程序:

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/

'driver' => 'mail',
相关问题