WordPress使用PHPMailer发送gmail邮件
wordpress使用phpmailer发送gmail邮件
0.保证用于gmail账号已经开启imap服务,且你能正常访问到gmail的smtp服务。(需要climb over the wall)
1.引入phpmailer相关类
原来在wp-includes里面有class-phpmailer.php和class-smtp.php两个文件,可以把它们拷贝到你需要编写发送邮件的那个文件的同级目录。然后引入代码如下:
include("class-phpmailer.php");
include("class-smtp.php");
- 2.设置phpmailer配置
$mail = new PHPMailer();
$body = "Hi, my friend, just a test for audience! from ssr@interbrands.com";
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
特别注意,要使用tls,而不是ssl。端口号为587,host为smtp.gmail.com。调试阶段可以设置SMTPDebug,否则应该删掉或者屏蔽这行的设置。
- 3.设置发送内容
$mail->Username = "fightforphp@gmail.com";
$mail->Password = "xxxxxxx";
$body = "This is a test message not in awe of creation."; // 邮件内容
$mail->setFrom('fightforphp@mail.com', 'HelpForEmail');
$mail->Subject = 'Ask for help now'; // 邮件主题
$mail->msgHTML($body);
$mail->CharSet = "utf-8";
$address = "xxx@gmail.com";
$mail->addAddress($address);
关键不在于怎么用PHPMailer,关键在于当我们处于某种特定技术框架下怎么样写出具有good smell 和 particular的写法。
WordPress使用PHPMailer发送gmail邮件的更多相关文章
- 使用phpmailer发送smtp邮件时提示 SMTP Error: Could not authenticate 错误
使用phpmailer发送smtp邮件时提示 SMTP Error: Could not authenticate 错误 这个错误是验证出现错误, $mail->Port = 25; //SMT ...
- 在Delphi中使用indy SMTP发送gmail邮件[转]
在Delphi中使用indy SMTP发送gmail邮件[转] 2012-01-01 22:44:30| 分类: Delphi | 标签: |举报 |字号大中小 订阅 在Delphi中发送 ...
- WordPress用户注册无法发送密码邮件怎么回事?
wordpress无法发送电子邮件.可能原因:您的主机禁用了 mail() 函数 等等几句话.在网上一搜,很快找到了解决方案:使用wp-mail-smtp插件. 一.插件下载安装.可以在wordpre ...
- 在命令行上 Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件
在命令行写email from ubuntu 参考: http://www.habadog.com/2011/11/23/send-mail-with-msmtp-mutt-linux ...
- Ubuntu 下使用 mutt 和 msmtp 发送 Gmail 邮件
参考: http://www.cnblogs.com/refrag/archive/2012/11/28/2793533.html http://www.habadog. ...
- ThinkPHP使用PHPmailer发送Email邮件
下面介绍thinkphp如何使用phpmailer发送邮件,使用这个邮件发送类,配置好参数后,一句话即可发送邮件.仅适合于thinkphp框架. 第一步,下载类库 将Mail.class.php复制到 ...
- Ubuntu下配置用msmtp发送gmail邮件
从https://gist.github.com/JosefJezek/6194563上找到的一个配置脚本,下载后添加可执行权限,然后运行即可. 下面是脚本setup-msmtp-for-gmail. ...
- PHPmailer群发Gmail的常见问题
博主小白一枚,phpmailer只会一些基本的用法,就这样一个邮件的群发功能也难住了我一周,下面把我遇到的问题给大家总结一下 1.Could not authenticate 首先,如果你没有使用循环 ...
- C#发送Email邮件(实例:QQ邮箱和Gmail邮箱)
下面用到的邮件账号和密码都不是真实的,需要测试就换成自己的邮件账号. 需要引用: using System.Net.Mail; using System.Text; using System.Net; ...
随机推荐
- vue v-for循环中key属性的使用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Python--day37--多进程
1,创建多进程(父进程和子进程) import os import time #多进程都要导入multiprocessing from multiprocessing import Process d ...
- Python--day34--socket模块的方法
官方文档对socket模块下的socket.send()和socket.sendall()的解释如下: sk.setblocking(False)方法 import socket sk = socke ...
- 2018-2-13-win10-uwp-获取指定的文件-AQS
title author date CreateTime categories win10 uwp 获取指定的文件 AQS lindexi 2018-2-13 17:23:3 +0800 2018-2 ...
- JPA查询之Specification以及HQL、SQL查询
1.Specification //查询条件List List<Predicate> predicateList = new ArrayList<Predicate>(); S ...
- linux 系统挂起
尽管内核代码的大部分 bug 以 oops 消息结束, 有时候它们可能完全挂起系统. 如果系 统挂起, 没有消息打印. 例如, 如果代码进入一个无限循环, 内核停止调度,[15]15 并且系 统不会响 ...
- linux 从用户空间的 I/O 存取
刚刚描述的这些函数主要打算被设备驱动使用, 但它们也可从用户空间使用, 至少在 PC- 类 的计算机. GNU C 库在 <sys/io.h> 中定义它们. 下列条件应当应用来对于 inb ...
- 【50.54%】【BZOJ 1879】[Sdoi2009]Bill的挑战
Time Limit: 4 Sec Memory Limit: 64 MB Submit: 649 Solved: 328 [Submit][Status][Discuss] Descriptio ...
- Recall(召回率);Precision(准确率);F1-Meature(综合评价指标);true positives;false positives;false negatives..
转自:http://blog.csdn.net/t710smgtwoshima/article/details/8215037 Recall(召回率);Precision(准确率);F1-Meat ...
- linux之旅首页
为什么有此系列文章 目录 为什么有此系列文章 一直使用windows,决定使用linux作为操作系统. 使用此系列文章来记录我使用linux过程中遇到的问题,和应对方式 目录 安装linux