php邮件库——swiftmailer
来源:互联网 发布:台湾人淘宝吗 编辑:程序博客网 时间:2024/06/06 07:28
github地址:https://github.com/swiftmailer/swiftmailer.git
require_once ("lib/swift_required.php");
// 创建Transport对象,设置邮件服务器和端口号,并设置用户名和密码以供验证
$transport = Swift_SmtpTransport::newInstance('smtp.163.com', 25)
->setUsername('username@163.com')
->setPassword('password');
// 创建mailer对象
$mailer = Swift_Mailer::newInstance($transport);
// 创建message对象
$message = Swift_Message::newInstance();
// 设置邮件主题
$message->setSubject('这是一份测试邮件')
// 设置邮件内容,可以省略content-type
->setBody(
'<html>' .
' <head></head>' .
' <body>' .
' Here is an image <img src="' . // 内嵌文件
$message->embed(Swift_Image::fromPath('image.jpg')) .
'" alt="Image" />' .
' Rest of message' .
'<a href="http://www.baidu.com">百度</a>'.
' </body>' .
'</html>',
'text/html'
);
// 创建attachment对象,content-type这个参数可以省略
$attachment = Swift_Attachment::fromPath('image.jpg', 'image/jpeg')
->setFilename('cool.jpg');
// 添加附件
$message->attach($attachment);
// 用关联数组设置收件人地址,可以设置多个收件人
$message->setTo(array('to@qq.com' => 'toName'));
// 用关联数组设置发件人地址,可以设置多个发件人
$message->setFrom(array(
'from@163.com' => 'fromName',
));
// 添加抄送人
$message->setCc(array(
'Cc@qq.com' => 'Cc'
));
// 添加密送人
$message->setBcc(array(
'Bcc@qq.com' => 'Bcc'
));
// 设置邮件回执
$message->setReadReceiptTo('receipt@163.com');
// 发送邮件
$result = $mailer->send($message);
阅读全文
0 0
- php邮件库——swiftmailer
- 高效的PHP邮件发送库:Swiftmailer
- PHP发送邮件swiftMailer
- 使用PHP邮件库swiftmailer发送邮件时,QQ,163邮箱的配置
- laravel 邮件SwiftMailer
- thinkphp 整合 swiftmailer 实现邮件发送
- yii 框架用swiftmailer 发送邮件
- yii 框架用swiftmailer 发送邮件
- Thinkphp整合swiftmailer实现邮件发送
- YII2 邮件插件SwiftMailer使用SendMail本地邮件服务器发送
- Laravel swiftmailer(messages) 发邮件,基于smtp或linux sendmail
- yii2.0利用yii2-swiftmailer扩展发送邮件
- yii2下swiftmailer发生邮件时,附件中文名的解决方法
- 在YII2中使用swiftmailer给多账号发送邮件和附件
- [L-php]PHP功能模块——发送邮件
- PHP——php脚本如何自动发送邮件
- thinkphp5使用swiftmailer
- PHPMailer / Zend-mail / SwiftMailer
- Android studio无法创建类和接口问题解决办法。提示 Unable to parse template "Class"
- 设计模式之简单工厂模式
- (小白)面向对象设计中接口的作用
- js笔记1-基本知识
- Ubuntu下安装Kdevelop IDE和使用教程
- php邮件库——swiftmailer
- JavaWeb笔记之快速了解Listener监听器
- MySQL锁与事务
- 虚拟文件系统、实际文件系统、日志文件
- java 提示:数据源建立连接的消息被拒绝,服务器:“太多的连接” 的解决办法
- hdu1284钱币兑换问题 (普通型母函数)
- 判断串中每种字符是否只出现一次,时间复杂度O(N)
- zuul报错java.net.UnknownHostException: 4d59d509898a: Name or service not known
- 面试代码题记录