博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
yii 邮箱封装
阅读量:6863 次
发布时间:2019-06-26

本文共 3082 字,大约阅读时间需要 10 分钟。

'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => 'xxx@163.com', 'password' => 'xxx', 'port' => '994', 'encryption' => 'ssl', //ssl tls ]; self::$obj = \Yii::createObject([ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => false, 'transport' => self::$config, ]); } return self::$obj; } public static function send($toEmail, $subject, array $compose) { $user = \Wskm::getUser(); if ($compose) {
        //同时设置2种内容,让用户的偏好自己选择 self::getMailer()->compose( //['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user] //['html' => 'passwordResetToken-html'], ['user' => $user] $compose ); }else{ self::getMailer()->setBody('My amazing body', 'text/html'); self::getMailer()->addPart('My amazing body in plain text', 'text/plain'); } //https://swiftmailer.symfony.com/docs/messages.html //addTo addCc addBcc //$message->setTo(['some@address.tld', 'other@address.tld']); //$message->setCc([ // 'person1@example.org', 'person2@otherdomain.org' => 'Person 2 Name', //]); //->attach(Swift_Attachment::fromPath('my-document.pdf')->setFilename('cool.jpg')) /* // Create the message $message = new Swift_Message('My subject'); // Set the body $message->setBody( '' . ' ' . ' Here is an image Image' . ' Rest of message' . ' ' . '', 'text/html' // Mark the content-type as HTML ); */ /* * 验证 use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\Validation\RFCValidation; $validator = new EmailValidator(); $validator->isValid("example@example.com", new RFCValidation()); */ /* * 加密 $smimeSigner = new Swift_Signers_SMimeSigner(); $smimeSigner->setSignCertificate('/path/to/certificate.pem', ['/path/to/private-key.pem', 'passphrase']); $message->attachSigner($smimeSigner); */ /* * 回执 $MESSAGE->setReadReceiptTo('你@地址。 TLD '); */ /** * ->setCharset('iso-8859-2'); 编码 * ->setPriority(2); 设置优先级,1-5 */ return self::getMailer()->compose( //['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user] ['html' => 'passwordResetToken-html'], ['user' => $user] ) ->setFrom([ self::$config['username'] => 'test robot']) ->setTo($toEmail) ->setSubject($subject) ->send(); }}

 

转载地址:http://ftqyl.baihongyu.com/

你可能感兴趣的文章
使用php分页类实现简单分类
查看>>
ReentrantLock可重入锁的使用场景(转)
查看>>
HDU 1075 What Are You Talking About (strings)
查看>>
浅谈电子政务门户建设选型经验
查看>>
被spring和hibernate4逼疯
查看>>
JAVA多线程之中断机制(如何处理中断?)
查看>>
Rotate It !!(思维)
查看>>
编译openjdk源码
查看>>
从一个前端项目实践 Git flow 的流程与参考
查看>>
mybatis 需要注意的点 MyBatis 插入空值时,需要指定JdbcType (201
查看>>
linux kill信号列表
查看>>
浅析主键自增长的优缺点
查看>>
codeforces水题100道 第五题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas (math)
查看>>
基于struts2和hibernate的登录和注册功能——完整实例
查看>>
私有IP地址共有三个范围段
查看>>
用bash命令得到Windows一个目录下的所有文件并且把结果输入到一个文件
查看>>
linux下mysql修改root密码
查看>>
Excel的合并解析
查看>>
MyBatis的动态SQL详解
查看>>
@ResponseBody
查看>>