<?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. Linux操作命令(五)

    find . -name ”*.c" -exec ./command.sh {} \; 本次实验将介绍 Linux 命令中 find 和 xargs 命令的用法. find xargs 1. ...

  3. 洛谷——P2009 跑步

    P2009 跑步 题目背景 跑步是一项有意思的运动,尤其是可以开发人的脑筋.常神牛很喜欢跑步. 题目描述 常神牛跑步的场地是一个多边形(边数≤20,每个顶点用英文大写字母表示),并且在这个多边形内部, ...

  4. 【BZOJ 2878】 2878: [Noi2012]迷失游乐园 (环套树、树形概率DP)

    2878: [Noi2012]迷失游乐园 Description 放假了,小Z觉得呆在家里特别无聊,于是决定一个人去游乐园玩.进入游乐园后,小Z看了看游乐园的地图,发现可以将游乐园抽象成有n个景点.m ...

  5. 【BZOJ 1998】 1998: [Hnoi2010]Fsk物品调度(双向链表+并查集+置换)

    1998: [Hnoi2010]Fsk物品调度 Description 现在找工作不容易,Lostmonkey费了好大劲才得到fsk公司基层流水线操作员的职位.流水线上有n个位置,从0到n-1依次编号 ...

  6. hdu 2955 Robberies(概率背包)

    Robberies Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  7. BZOJ 1633 [Usaco2007 Feb]The Cow Lexicon 牛的词典(单调DP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1633 [题目大意] 给出一个字符串和一个字符串集, 问要删去多少个字符该字符串才可以被 ...

  8. 【转载】Java中String类的方法及说明

    转载自:http://www.cnblogs.com/YSO1983/archive/2009/12/07/1618564.html String : 字符串类型 一.      String sc_ ...

  9. 重拾vue2

    Vue组件 一.组件介绍 每一个组件都是一个vue实例 每个组件均具有自身的模板template,根组件的模板就是挂载点 每个组件模板只能拥有一个根标签 子组件的数据具有作用域,以达到组件的复用 二. ...

  10. [PKUSC2018]最大前缀和

    [PKUSC2018]最大前缀和 题目大意: 有\(n(n\le20)\)个数\(A_i(|A_i|\le10^9)\).求这\(n\)个数在随机打乱后最大前缀和的期望值与\(n!\)的积在模\(99 ...