PHPMailer_v5.1 使用[转]
<?php
/*
* email 报警,主要检查服务器数据库是否还能正常连接
*/
require("../common/config.php"); include("../common/class.phpmailer.php");
include("../common/class.smtp.php"); // note, this is optional - gets called from main class if not already loaded
$conn = mysql_connect($_SC['dbhost'],$_SC['dbuser'],$_SC['dbpw']);
if(!$conn){
sendAlarmEmail();
die("连接数据库失败");
exit();
}else{
echo '数据库连接成功';
} function sendAlarmEmail(){ $mail = new PHPMailer();
//$body = $mail->getFile('a.htm');
//$body = eregi_replace("[\]",'',$body); $mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.qq.com"; // sets GMAIL as the SMTP server
$mail->Port = 25; // set the SMTP port $mail->Username = "827798208@qq.com"; // GMAIL username
$mail->Password = "******"; // GMAIL password $mail->From = "827798208@qq.com";
$mail->FromName = "sinykk";
$mail->Subject = "company server mysql caught error";
//$mail->AltBody = "This is the body when user views in plain text format附加内容"; //Text Body
$mail->WordWrap = 50; // set word wrap //$mail->MsgHTML($body);
$mail->Body="company server mysql caught error ip 122..."; $mail->AddReplyTo("sinykk@yeah.net","sinykk"); //$mail->AddAttachment("/path/to/file.zip"); // attachment
//$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment $mail->AddAddress("158688466XX@139.com","sinykk_mobile"); $mail->IsHTML(false); // send as HTML if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
} ?>
感谢! 来自:http://sinykk.iteye.com/blog/990670
PHPMailer_v5.1 使用[转]的更多相关文章
- 我的PHPMailer_v5.1 使用
<?php /** * Simple example script using PHPMailer with exceptions enabled * @package phpmailer * ...
- Thinkphp 使用gmail发送邮件
1.Thinkphp 发送邮件内容来自:http://www.thinkphp.cn/code/32.html /** * 系统邮件发送函数 * @param string $to 接收邮件者邮箱 * ...
- tp 邮件发送
1.需要phpmail邮件发送包, 2.邮件发送函数function sendMail($to, $title, $content){ require_once('./PHPMailer_v5.1/c ...
随机推荐
- Aras Innovator 11 sp2安装
本文档记录Aras Innovator 11 sp2的安装过程 官方安装文档:http://www.aras.com/support/documentation/ Aras Innovator 11. ...
- Nodejs创建简单的Bot
官方文档地址:https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-quickstart 前提: 1.你已经 ...
- Mac OS X系统下的Android环境变量配置
在Mac下开发Android,要想在终端利用命令行使用adb/android等命令时,需要配置一下环境变量. 步骤: 1.首先,假设你已经下载了Android SDK,解压后安装了adb.记住sdk文 ...
- gradle打包分编译环境
gradle打包分测试.开发.生产环境 buildTypes { debug { signingConfig signingConfigs.myConfig buildConfigField(&quo ...
- Loj#6432「PKUSC2018」真实排名(二分查找+组合数)
题面 Loj 题解 普通的暴力是直接枚举改或者不改,最后在判断最后对哪些点有贡献. 而这种方法是很难优化的.所以考虑在排序之后线性处理.首先先假设没有重复的元素 struct Node { int p ...
- Linux含交互的自动登录脚本
近来经常要通过ssh登录服务器,每次输入命令和密码很麻烦,查资料发现有两种解决,一种是本地创建密钥直接登录,另一种是写个脚本. 这里介绍第二种方法,第一种资料也很多,但是觉得没啥意思. 先上脚本: # ...
- 【rope】bzoj1269 [AHOI2006]文本编辑器editor
维护一个字符串,支持以下操作: 主要就是 成段插入.成段删除.成段翻转.前两个操作很好通过rope实现.第三个操作也不难,维护两个rope,一个正向,一个反向,翻转时swap一下就行了. ro ...
- Java编程思想学习(三)----第三章:操作符
3.2使用Java操作符 操作符接受一个或多个参数,并生成一个新值. 操作符作用于操作数,生成一个新值.有些操作符可以改变操作数自身的值.几乎所以的操作符都只能操作“基本类型”.例外的操作符有“=”, ...
- JAVA EE 中之AJAX 无刷新地区下拉列表三级联动
JSP页面 <html> <head> <meta http-equiv="Content-Type" content="text/html ...
- [转]Spring 中的p标签
spring的bean配置文件中p:代表什么 <bean id="daoTemplate" abstract="true" lazy-init=" ...