laravel config mail

作者: 3275508ab630 | 来源:发表于2017-12-15 21:00 被阅读24次

    mail.php

    driver 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | 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", "sendmail", "mailgun", "mandrill", "ses",
        |            "sparkpost", "log", "array"
        |
        */
    
        'driver' => env('MAIL_DRIVER', 'smtp'),
    
        /*
        |--------------------------------------------------------------------------
        | 邮件驱动
        |--------------------------------------------------------------------------
        |
        | Laravel支持SMTP和PHP的“邮件”功能作为发送电子邮件的驱动程序。 
        | 你可以在这里为你的应用程序指定使用哪种驱动。 
        | 默认情况下,Laravel使用SMTP发送邮件。
        |
        | 支持: "smtp", "sendmail", "mailgun", "mandrill", "ses",
        |            "sparkpost", "log", "array"
        |
        */
    
        'driver' => env('MAIL_DRIVER', 'smtp'),
    

    个人理解:log 会把邮件发送到日志里,做测试方便。除了 smtp 其他的笔者都没用过。可以看
    作者:王宝花 链接:利用Laravel自带SMTP邮件组件实现发送邮件 來源:简书

    host 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | SMTP Host Address
        |--------------------------------------------------------------------------
        |
        | Here you may provide the host address of the SMTP server used by your
        | applications. A default option is provided that is compatible with
        | the Mailgun mail service which will provide reliable deliveries.
        |
        */
    
        'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    
        /*
        |--------------------------------------------------------------------------
        | SMTP 主机地址
        |--------------------------------------------------------------------------
        |
        | 这里您可以提供应用程序使用的SMTP服务器的主机地址。 
        | 请提供一个与Mailgun邮件服务兼容可靠的默认选项。
        | 
        |
        */
    
        'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
    

    个人理解:发邮件的主机地址,让它发送邮件。

    port 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | SMTP Host Port
        |--------------------------------------------------------------------------
        |
        | This is the SMTP port used by your application to deliver e-mails to
        | users of the application. Like the host we have set this value to
        | stay compatible with the Mailgun e-mail application by default.
        |
        */
    
        'port' => env('MAIL_PORT', 587),
    
        /*
        |--------------------------------------------------------------------------
        | SMTP 主机端口
        |--------------------------------------------------------------------------
        |
        | 这是您的应用程序用于向应用程序的用户发送电子邮件的SMTP端口。 
        | 与主机一样,我们已经设置了这个值,以保持与Mailgun电子邮件应用程序的默认兼容。
        | 
        |
        */
    
        'port' => env('MAIL_PORT', 587),
    

    个人理解:发邮件的端口号,如果使用了 SSL 加密,端口号要改成 465 ,比如qq邮箱。

    from 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | 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' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
            'name' => env('MAIL_FROM_NAME', 'Example'),
        ],
    
        /*
        |--------------------------------------------------------------------------
        | 全局 "From" 地址
        |--------------------------------------------------------------------------
        |
        | 您可能希望您的应用程序发送的所有电子邮件都使用相同的地址发送。 
        | 在这里,您可以指定一个名称和地址,让所有电子邮件使用该名称和地址发送。
        | 
        |
        */
    
        'from' => [
            'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
            'name' => env('MAIL_FROM_NAME', 'Example'),
        ],
    

    个人理解:address 是发送者邮箱地址,name 填网站名。

    encryption 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | E-Mail Encryption Protocol
        |--------------------------------------------------------------------------
        |
        | Here you may specify the encryption protocol that should be used when
        | the application send e-mail messages. A sensible default using the
        | transport layer security protocol should provide great security.
        |
        */
    
        'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    
        /*
        |--------------------------------------------------------------------------
        | 电子邮件加密协议
        |--------------------------------------------------------------------------
        |
        | 这里您可以指定应用程序发送电子邮件时应使用的加密协议。 
        | 使用传输层安全协议的合理默认应该提供很高的安全性。
        | 
        |
        */
    
        'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    

    个人理解:加密方式,可以填 tls ssl 。没有加密的填 null

    username 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | SMTP Server Username
        |--------------------------------------------------------------------------
        |
        | If your SMTP server requires a username for authentication, you should
        | set it here. This will get used to authenticate with your server on
        | connection. You may also set the "password" value below this one.
        |
        */
    
        'username' => env('MAIL_USERNAME'),
    
        'password' => env('MAIL_PASSWORD'),
    
        /*
        |--------------------------------------------------------------------------
        | SMTP服务器用户名
        |--------------------------------------------------------------------------
        |
        | 如果您的SMTP服务器需要用户名进行身份验证,则应在此处进行设置。 
        | 这将用于在连接时与您的服务器进行身份验证。 你也可以在这个下面设置“密码”的值。
        | 
        |
        */
    
        'username' => env('MAIL_USERNAME'),
    
        'password' => env('MAIL_PASSWORD'),
    

    个人理解:发送邮件需要的登录账号和密码。

    sendmail 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | Sendmail System Path
        |--------------------------------------------------------------------------
        |
        | When using the "sendmail" driver to send e-mails, we will need to know
        | the path to where Sendmail lives on this server. A default path has
        | been provided here, which will work well on most of your systems.
        |
        */
    
        'sendmail' => '/usr/sbin/sendmail -bs',
    
        /*
        |--------------------------------------------------------------------------
        | Sendmail系统路径
        |--------------------------------------------------------------------------
        |
        | 当使用“sendmail”驱动程序发送电子邮件时,我们需要知道Sendmail所在的服务器的路径。 
        | 这里提供了一个默认的路径,这在你的大部分系统上都能正常工作。
        | 
        |
        */
    
        'sendmail' => '/usr/sbin/sendmail -bs',
    

    个人理解:驱动使用 sendmail 这个有用。

    markdown 注释翻译:

        /*
        |--------------------------------------------------------------------------
        | Markdown Mail Settings
        |--------------------------------------------------------------------------
        |
        | If you are using Markdown based email rendering, you may configure your
        | theme and component paths here, allowing you to customize the design
        | of the emails. Or, you may simply stick with the Laravel defaults!
        |
        */
    
        'markdown' => [
            'theme' => 'default',
    
            'paths' => [
                resource_path('views/vendor/mail'),
            ],
        ],
    
        /*
        |--------------------------------------------------------------------------
        | Markdown邮件设置
        |--------------------------------------------------------------------------
        |
        | 如果您使用基于Markdown的电子邮件渲染,则可以在此处配置主题和组件路径,
        | 从而允许您自定义电子邮件的设计。 或者,你可以简单地坚持Laravel的默认值!
        | 
        |
        */
    
        'markdown' => [
            'theme' => 'default',
    
            'paths' => [
                resource_path('views/vendor/mail'),
            ],
        ],
    

    个人理解:发送 Markdown 格式的邮件。

    to 注释翻译:

        'to' => [
            'address' => 'example@example.com',
            'name' => 'Example'
        ],
    

    个人理解:默认没有,文档中有提到。Laravel 提供的另一种解决方案是为框架发送的所有邮件设置通用收件人,这样的话,所有应用生成的邮件将会被发送到指定地址,而不是实际发送邮件指定的地址。这可以通过在配置文件 config/mail.php 中设置 to 选项来实现

    相关文章

      网友评论

        本文标题:laravel config mail

        本文链接:https://www.haomeiwen.com/subject/mefjwxtx.html