转载 http://blog.csdn.net/liruxing1715/article/details/7914974

PHPMailer 的官方网站:http://phpmailer.worxware.com/

PHPMailer 最新类库下载地址:【点击下载

PHPMailer GitHub 下载地址:https://github.com/Synchro/PHPMailer,该页面也提供了使用例子,不过不是很全面。

使用方法,详见代码清单:

<?php
header('Content-Type:text/html;Charset=utf-8');
require './PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // 设置邮件使用SMTP
$mail->Host = 'mail.wanzhao.com'; // 邮件服务器地址
$mail->SMTPAuth = true; // 启用SMTP身份验证
$mail->CharSet = "UTF-8"; // 设置邮件编码
$mail->setLanguage('zh_cn'); // 设置错误中文提示
$mail->Username = 'wanzhao@wanzhao.com'; // SMTP 用户名,即个人的邮箱地址
$mail->Password = 'www123456'; // SMTP 密码,即个人的邮箱密码
$mail->SMTPSecure = 'tls'; // 设置启用加密,注意:必须打开 php_openssl 模块
$mail->Priority = 3; // 设置邮件优先级 1:高, 3:正常(默认), 5:低
$mail->From = 'liruxing@wanzhao.com'; // 发件人邮箱地址
$mail->FromName = '李茹星'; // 发件人名称
$mail->addAddress('liruxing1715@163.com', 'Lee'); // 添加接受者
$mail->addAddress('ellen@example.com'); // 添加多个接受者
$mail->addReplyTo('info@example.com', 'Information'); // 添加回复者
$mail->addCC('liruxing1715@sina.com'); // 添加抄送人
$mail->addCC('512848303@qq.com'); // 添加多个抄送人
$mail->ConfirmReadingTo = 'liruxing@wanzhao.com'; // 添加发送回执邮件地址,即当收件人打开邮件后,会询问是否发生回执
$mail->addBCC('734133239@qq.com'); // 添加密送者,Mail Header不会显示密送者信息
$mail->WordWrap = 50; // 设置自动换行50个字符
$mail->addAttachment('./1.jpg'); // 添加附件
$mail->addAttachment('/tmp/image.jpg', 'one pic'); // 添加多个附件
$mail->isHTML(true); // 设置邮件格式为HTML
$mail->Subject = 'Here is the 主题';
$mail->Body = 'This is the HTML 信息 body <b>in bold!</b>. Time:'.date('Y-m-d H:i:s');
$mail->AltBody = 'This is the 主体 in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}

echo 'Message has been sent';

使用 PHPMailer 发送邮件的更多相关文章

  1. 利用PHPMailer发送邮件时报错

    利用thinkphp集成PHPMailer发送邮件时报错:Failed to connect to server: Unable to find the socket transport “ssl” ...

  2. 使用PHPmailer发送邮件的详细代码

    一.使用PHPMailer发送邮件的原因 PHP有内置的mail()方法,但是由于一些主机空间不支持该方法,所以经常会遇到无法发送邮件的情况. 所以,可以下载PHPMailer类,实现邮件发送. 二. ...

  3. ThinkPHP 中使用 PHPMailer 发送邮件 支持163和QQ邮箱等

    [摘要]ThinkPHP是一个开源的PHP框架, 是为了简化企业级应用开发和敏捷WEB应用开发而诞生的.本文介绍ThinkPHP 中使用 PHPMailer 发送邮件. PHP是自带可以发送邮件的Ma ...

  4. 在Thinkphp3.2 中使用PHPMailer 发送邮件

    phpmailer发送邮件是php开发者首选的一个邮件发送插件了,下面我来介绍怎么集成phpmailer到thinkphp框架了,有需要了解的朋友可参考. phpmailer发送邮件功能很强大,今天真 ...

  5. PHPMailer 发送邮件(二)

    发现PHPMailer又做了较大的更新,以前发送邮件的方法已不太适用,刚好要做一个实验,需要搭建个环境,这里使用Gmail进行测试,现记录下来. 传送地址Github: PHPMailer 基本要求的 ...

  6. 用phpmailer发送邮件提示SMTP Error: Could not connect to SMTP host解决办法

    之前做项目的时候做了一个用phpmailer发送邮件的功能<CI框架结合PHPmailer发送邮件>,昨天步署上线(刚开始用新浪云,嫌贵,换成阿里了),测试的时候,发送邮件却意外报错了.. ...

  7. thinkphp使用PHPMailer发送邮件

    第一步:准备PHPMailer 使用PHPMailer发送邮件,首先下载个PHPMailer 将下载的PHPMailer放到ThinkPHP文件夹里面的ThinkPHPExtendVendor 第二步 ...

  8. PHPMailer发送邮件中文附件名是乱码

    可能使用了PHPMailer发送邮件的朋友带中文附件名时会出现乱码,下面我来介绍一个解决办法. 比如我们要发送的附件是"测试.txt",如果在添加附件的时候强制使用指定文件名的方式 ...

  9. phpmailer发送邮件

    phpmailer发送邮件 PHP内置的mail函数使用起来不够方便,另外受其他语言的影响,博主更偏好面向对象的包管理模式,因此phpmailer成为了我用PHP发送邮件的首选,这里分享给大家. 库导 ...

  10. PHPmailer发送邮件时的常见问题及解决办法

    来源:http://www.chinastor.com/a/jishu/mailserver/0G392262014.html 使用PHPmailer发送邮件时的常见问题总结: 一,没有定义发送邮箱$ ...

随机推荐

  1. SQL--空值处理

    --为空 SELECT * FROM dbo.Product WHERE Price IS NULL --不为空 SELECT * FROM dbo.Product WHERE Price IS NO ...

  2. DirectX.Capture Class Library

    DirectX.Capture Class Library Brian Low,              29 Mar 2008                                    ...

  3. HoverTree系统源码介绍

    HoverTree是一个开源asp.net系统.系统的效果请到:http://hovertree.com体验. 源码描述:一.源码特点采用典型的三层架构进行开发,实现了留言板的功能,后台管理,留言审核 ...

  4. 使用CallerMemberName简化InotifyPropertyChanged的实现

    在WPF中,当我们要使用MVVM的方式绑定一个普通对象的属性时,界面上往往需要获取到属性变更的通知,     class NotifyObject : INotifyPropertyChanged   ...

  5. css: 照片有如层叠效果

    显示上面照片效果css <!DOCTYPE html> <!--headTrap<body></body><head></head>& ...

  6. Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

    在Eclipse中开发Android项目时,鼠标停放在想要查看帮助文档的类上面,发现没有显示帮助文档,显示了下面一句话: Note: This element neither has attached ...

  7. Titanium Studio下载地址

    http://titanium-studio.s3.amazonaws.com/latest/titanium.studio.linux.gtk.x86_64.zip http://titanium- ...

  8. mysql学习笔记 第四天

    mysql引擎: archive(档案)[数据插入以后不能被修改,只读] blackhole[这种写操作是删除数据,读操作是返回空白记录] CSV[在储存数据时以逗号作为数据项之间的分隔符] exam ...

  9. Scalaz(16)- Monad:依赖注入-Dependency Injection By Reader Monad

    在上一篇讨论里我们简单的介绍了一下Cake Pattern和Reader Monad是如何实现依赖注入的.主要还是从方法上示范了如何用Cake Pattern和Reader在编程过程中解析依赖和注入依 ...

  10. Erlang垃圾回收机制的二三事

    声明:本片文章是由Hackernews上的[Erlang Garbage Collection Details and Why ItMatters][1]编译而来,本着学习和研究的态度,进行的编译,转 ...