【发布时间】:2014-08-29 07:41:21
【问题描述】:
这可能是一个愚蠢的问题,但我使用的是 Laravel 4.2。我正在使用 Laravel 发送电子邮件,我知道 Laravel 带有 SwiftMailer。如果我像下面的代码一样调用 Mail::send,我是在调用 SwiftMailer 的邮件库还是在调用 PHP 的邮件库?那么,这两者有什么区别呢?
app/config/mail.php
return array(
'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => 'my_gmail_username.gmail.com', 'name' => 'Test Email'),
'encryption' => 'ssl',
'username' => 'my_gmail_username',
'password' => 'my_gmail_password',
'sendmail' => '/usr/sbin/sendmail -bs',
app/routes.php
namespace MyMail;
use Mail;
Mail::send('mail_template1', array('name' => 'Laravel'), function($message) use ($arr_index)
{
$message->to('name@email.com', 'name')
->from('different_email@gmail.com', 'Another name')
->subject('Laravel Email Test 1');
});
【问题讨论】:
-
Mail::send 只是 swift mailer 的 laravel 包装器,所以你在调用时调用了 swift mailer
标签: php email laravel-4 swiftmailer