<?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 使用[转]的更多相关文章

  1. 我的PHPMailer_v5.1 使用

    <?php /** * Simple example script using PHPMailer with exceptions enabled * @package phpmailer * ...

  2. Thinkphp 使用gmail发送邮件

    1.Thinkphp 发送邮件内容来自:http://www.thinkphp.cn/code/32.html /** * 系统邮件发送函数 * @param string $to 接收邮件者邮箱 * ...

  3. tp 邮件发送

    1.需要phpmail邮件发送包, 2.邮件发送函数function sendMail($to, $title, $content){ require_once('./PHPMailer_v5.1/c ...

随机推荐

  1. 线程间操作无效: 从不是创建控件“textBox2”的线程访问它

    如何:对 Windows 窗体控件进行线程安全调用 线程间操作无效: 从不是创建控件的线程访问它的三种方法 如果使用多线程处理来提高 Windows 窗体应用程序的性能,则你必须确保以线程安全的方式调 ...

  2. mtk预装apk 方案公司内置预装apk

    mtk预装apk 方案公司内置预装apk 韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha == MTK 预知第三方的APK 流程_yua ...

  3. [USACO 2017 Jan Gold] Tutorial

    Link: 传送门 A: 按值大小插入后用树状数组统计两边个数 #include <bits/stdc++.h> using namespace std; #define X first ...

  4. 【树形dp】Rebuilding Roads

    [POJ1947]Rebuilding Roads Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 11934   Accep ...

  5. BZOJ 1098 [POI2007]办公楼biu(反向图bfs+并查集优化)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1098 [题目大意] 现在有一张图,要求将这张图的点划分为尽量多的分组,对于不同分组的两 ...

  6. Generator函数(三)

    Generator.prototype.return() 1.Generator函数返回的遍历器对象还有一个return方法,可以返回给定的值,并终结Generator函数的遍历. function* ...

  7. PHP与mysql数据库

    1.PHP访问数据库的一般步骤 连接MySQL服务器 选择MySQL数据库 执行SQL语句(增,删,改,查) 关闭结果集,释放资源 关闭MySQL服务器的连接 需要查的表的数据: 2.连接和关闭实例 ...

  8. Inno Setup入门(十八)——Inno Setup类参考(4)

    http://379910987.blog.163.com/blog/static/3352379720112122533866/ 编辑框 编辑框也叫文本框,是典型的窗口可视化组件,既可以用来输入文本 ...

  9. linux下的udev是干嘛的,能否说的通俗点

    转:http://www.360doc.com/content/11/0415/21/1317564_109924863.shtml 早期的linux的/dev目录下有一大堆设备文件,不管你的主机上是 ...

  10. iOS中TextView显示HTML文本

    在界面布局中,我们会用到各种控件来显示我们想要的数据来进行展示:之前遇到过这样一个问题,我从后台的数据传过来是json,解析过后直接放入一个TextView来进行显示,但是没注意到这个数据里面是HTM ...