PHP使用SwiftMailer发送邮件
用到了swiftmailer 的lib库
require_once 'lib/swift_required.php';
//给我发送邮件
function mailer(){
$body ="要发送的内容";
$subject = "要发送主题"
$transport = Swift_SmtpTransport::newInstance('smtp.qq.com', 25);//设置发送 smtp 服务器和端口
$transport->setUsername('发送邮箱 地址 ');
$transport->setPassword('发送邮箱密码');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance();
$message->setFrom(array( '发送邮箱地址' =>'发送人'));
$message->setTo(array('接受邮箱地址' => '接受人'));
$message->setSubject($subject);
$message->setBody($body, 'text/html', 'utf-8');
//$message->attach(Swift_Attachment::fromPath('pic.jpg', 'image/jpeg')->setFilename('rename_pic.jpg'));//发送附件
try{
$mailer->send($message);
}
catch (Swift_ConnectionException $e){
echo 'There was a problem communicating with SMTP: ' . $e->getMessage();
}
}
Swift 直接与 SMTP 服务器通讯,具有非常高的发送速度和效率。
Swiftmailer的特点:
- Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own
- Support servers that require username & password and/or encryption
- Protect from header injection attacks without stripping request data content
- Send MIME compliant HTML/multipart emails
- Use event-driven plugins to customize the library
- Handle large attachments and inline/embedded images with low memory use
PHP使用SwiftMailer发送邮件的更多相关文章
- SwiftMailer 发送邮件时 提示fsockopen() 被禁用
站点转移空间,发送邮件的SwiftMailer 类提示错误如下: Warning: fsockopen() has been disabled for security reasons in D:\1 ...
- thinkphp 整合 swiftmailer 实现邮件发送
thinkphp swiftmailer(phpmailer) 文件夹结构 图 1 swiftmailer-phpmailer 将swiftmailer整合到thinkphp中.如上图 1 我下载的版 ...
- yii2-user 一个好用的用户扩展
最近使用yii2做了一个系统,涉及到了用户登录等等,之前是自己写的一套,后来要添加邮箱验证功能.有点懒,然后看到了yii2-user这个扩展.简单说下,毕竟自己研究也不深. http://yii2-u ...
- Yii2 advance swiftmailer 不能发送邮件
我用的是Yii2高级模板,在配置好邮箱后,并编写测试,测试结果表明是发送成功的,但我的邮箱就是接受不了邮件. 经过排查发现,是由 common/config/main-local.php 文件的 'u ...
- yii2 发送邮件 yii\swiftmailer\Mailer
Yii2 中发送邮件 yii\swiftmailer\Mailer 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath ...
- 分享一个php邮件库——swiftmailer
最近看到一个好的php邮件库,与phpmailer作用一样,但性能比phpmailer好,尤其是在处理附件的能力上,发送邮件成功的几率也高. github地址:https://github.com/s ...
- ThinkPHP 3.2.3 使用 Swift Mailer 邮件系统发送邮件
SwiftMailer 下载地址:https://github.com/swiftmailer/swiftmailer 版本:swiftmailer-5.x 把压缩包解压到 /ThinkPHP/Lib ...
- yii2发送邮件教程
作者:白狼 出处:http://www.manks.top/article/yii2_swiftMailer本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接, ...
- [moka同学笔记]YII2中发送邮件示例(转载)
原文:http://yiilib.com/topic/675/Yii2%E4%B8%AD%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6%E7%A4%BA%E4%BE%8B { ...
随机推荐
- secureCRT简单上传、下载文件记录
secureCRT简单上传.下载文件记录: 1)sz下载 -y 覆盖 2)rz上传 -y 覆盖 3)以上两个命令属于安装时包含在“Dial-up Networking Support"组中 ...
- find grep
grep grep -rn "hello,world!" * #递归查找当前目录下所有包含hello,world的文件 grep -C number pattern files : ...
- hdu 2222 Keywords Search ac自动机入门
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2222 题意:有N(N <= 10000)个长度不超过50的模式串和一个长度不超过1e6的文本串. ...
- 自定义MVC路由配置
首先我用MVC4新增一个订单查看的功能 1.创建控制器OrderController namespace MvcApplication3.Controllers { public class Orde ...
- 拖尾渲染器 Trail Renderer
拖尾渲染器(Trail Renderer)用于制作跟在场景中的物体后面的拖尾效果来代表它们在到处移动. 必须给Materials一个材质渲染器设置的Colors才有效. 展示自己的一个demo...
- 创建第一个UI
创建一个2D UI 制作UI时,首先要创建UI的"根".在Unity顶部NGUI菜单中选择Create,然后选择2D UI. 创建完成后,在Scene窗口中,NGUI自动生成了一个 ...
- jquery upload
http://blueimp.github.io/jQuery-File-Upload/ https://github.com/blueimp/jQuery-File-Upload/wiki Back ...
- SQL Server 修改排序规则
Net stop mssqlserver Setup /QUIET /ACTION=REBUILDDATABASE /instancename=mssqlserver /SQLSYSADMINACCO ...
- C++ dll调用-动态(显式)
C++ dll调用-动态(显式) 废话不说上代码, dll 头文件 j_test.h #pragma once extern "C"_declspec(dllexport) voi ...
- about mobile web
http://blog.csdn.net/kavensu/article/details/8722268 http://cavenfeng.iteye.com/blog/1551516 http:// ...