php - Laravel Mail 与 swiftmailer 之间的区别

标签 php email laravel-4 swiftmailer

这可能是一个愚蠢的问题,但我正在使用 Laravel 4.2。我正在使用 Laravel 发送电子邮件,并且我知道 Laravel 附带 SwiftMailer。如果我像下面的代码那样调用 Mail::send,我是调用 SwiftMailer 的 Mail 库还是调用 PHP 的 Mail 库?那么,两者有什么区别呢?

应用程序/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',

应用程序/routes.php

namespace MyMail;    
use Mail;

Mail::send('mail_template1', array('name' => 'Laravel'), function($message) use ($arr_index)
            {
                $message->to('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="87e9e6eae2c7e2eae6eeeba9e4e8ea" rel="noreferrer noopener nofollow">[email protected]</a>', 'name')
                        ->from('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04606d62626176616a705b6169656d68446369656d682a676b69" rel="noreferrer noopener nofollow">[email protected]</a>', 'Another name')
                        ->subject('Laravel Email Test 1');  
            });

最佳答案

Laravel provides a clean, simple API over the popular SwiftMailer library.

关于 php 邮件:

If you wish to use the PHP mail function to send mail, you may change the driver to mail in the configuration file.

Mail::send 只是 swift mailer 的 laravel 包装器,因此在执行该调用时您将调用 swift mailer,除非您将 'driver' => 'smtp' 更改为 'driver ' => 'mail',这样才会使用PHP的邮件。

引用:Laravel Mail Documentation

关于php - Laravel Mail 与 swiftmailer 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25563724/

相关文章:

apache - Laravel 4.1 登录路由显示空白页

Laravel:Eloquent 如何一次性更新模型和相关模型

java - 我如何处理 Microsoft outlook winmail.dat?还有什么惊喜吗?

Android 远程或推送配置文件

php - laravel 如何添加一对一关系

php - 空合并运算符是否调用一个函数两次?

php - 为社交网站创建提要

php - 如何查看在 codeigniter 中具有相同字段名称的连接表中的数据

javascript - 如何修复 google places api initMap 不是函数?

node.js - hapijs joi 电子邮件验证选项 tldWhitelist 用法