zoukankan      html  css  js  c++  java
  • Yii2 发送邮件 yiiswiftmailerMailer

    Yii2 中发送邮件 yiiswiftmailerMailer

            'mailer' => [
                'class' => 'yiiswiftmailerMailer',
                'viewPath' => '@common/mail',
                'useFileTransport' => false,
                'transport' => [
                    'class' => 'Swift_SmtpTransport',
                    'host' => 'smtpdm.aliyun.com',
                    'username' => '用户名',
                    'password' => '密码',
                    'port' => '端口',//阿里云的是80,宝塔中这里一定要有端口,阿里云是80
                    'encryption' => 'tls',
                ],
                'messageConfig'=>[
                    'charset'=>'UTF-8',
                    'from'=>['***@qq.com'=>'dafei']
                ],
            ],

    php 中调用

            Yii::$app->mailer->compose()
                ->setFrom(Yii::$app->get('mailer')->getTransport()->getUsername())//获取 mailer-->transport-->username , 即上面的用户名
                // ->setBcc(['123'=>'abc'])
                ->setTo('发送给谁@qq.com')
                ->setSubject('subject')
                ->setTextBody('hello world textBody')
                ->send();
            exit('发送邮件ok');
  • 相关阅读:
    newman
    集合自动化
    56. Merge Intervals
    55. Jump Game
    48. Rotate Image
    34. Search for a Range
    33. Search in Rotated Sorted Array
    16. 3Sum Closest
    15. 3Sum
    11. Container With Most Water
  • 原文地址:https://www.cnblogs.com/dafei4/p/11155285.html
Copyright © 2011-2022 走看看