<?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. PHP文件包含小结

    协议 各种协议的使用有时是关键 file协议 file后面需是///,例如file:///d:/1.txt 也可以是file://e:/1.txt,如果是在当前盘则可以file:///1.txt 如果 ...

  2. 最全python面试题

    Python语言特性 1 Python的函数参数传递 看两个例子: a = 1 def fun(a): a = 2 fun(a) print a # 1 a = [] def fun(a): a.ap ...

  3. hdu 1011(Starship Troopers,树形dp)

    Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...

  4. [Codeforces 1053C] Putting Boxes Together

    Link: Codeforces 1053C 传送门 Solution: 先推出一个结论: 最后必有一个点不动且其为权值上最中间的一个点 证明用反证证出如果不在中间的点必有一段能用代价少的替代多的 这 ...

  5. 【bzoj1594】猜数游戏

    1594: [Usaco2008 Jan]猜数游戏 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 556  Solved: 225 Descripti ...

  6. [ARC103F]Distance Sums

    题意:有一棵树,对于每个点$i$,给出了它到其他点的距离和$i$,现在要还原这棵树,保证$d_i$两两不同 一个点从$u$移到相邻节点$v$时,若删掉$(u,v)$后$u$这边的连通块大小为$siz_ ...

  7. 【枚举】bzoj1072 [SCOI2007]排列perm

    暴力,next_permutation函数用于枚举出下一个排列.sscanf函数用于将字符串转化成数字. #include<cstdio> #include<cstring> ...

  8. SpringBoot 整合 Jpa

    项目目录结构 pom文件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=&quo ...

  9. MYSQL复习笔记12-视图

    Date: 20140223Auth: Jin参考:http://blog.sina.com.cn/s/blog_436732df0100e768.html 一.介绍1.概念视图是从一个或几个基本表( ...

  10. ms_sql_server_architecture

    We have classified the architecture of SQL Server into the following parts for easy understanding − ...