<?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. 推荐开源靶场Vulhub

    转:https://github.com/phith0n/vulhub Vulhub - Some Docker-Compose files for vulnerabilities environme ...

  2. Java网络编程一

    1.InetAddress的应用 import java.util.List; import java.math.BigDecimal; import java.net.InetAddress; im ...

  3. 树形DP题目集合

    [树形DP](https://cn.vjudge.net/contest/123963#overview) #include<cstdio> #include<string> ...

  4. POJ3468 A Simple Problem with Interger [树状数组,差分]

    题目传送门 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 1 ...

  5. go chapter 8 - 初始化对象

    http://blog.haohtml.com/archives/14239 struct定义的属性如果是小写开头的,那么该属性不是public的,不能跨包调用 (implicit assignmen ...

  6. 自定义word快捷键,设置插入图片快捷键

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 自定义word快捷键,设置插入图片快捷键 文件→选项→自定义功能区 选择键盘快捷方式 自 ...

  7. 【BFS】【并查集】【Tarjan】【LCA】Gym - 101173H - Hangar Hurdles

    给你一张地图,给你q次询问,每次问你从A点到B点,最大能移动多大的箱子. 把每个点所能容纳的最大箱子求出来(BFS,八连通,一开始将所有边界点和障碍点入队).然后从大到小排序.然后用并查集将相邻(四联 ...

  8. mysql数据操作

    了解:Mysql 账号相关 创建账号: 权限:user(所有库的权限)-->db(某个库的权限)-->table_priv(某张表的权限) -->columns_oriv(某个字段的 ...

  9. nginx和php-fpm的用户权限

    启动php-fpm sudo php-fpm -c /etc/php.ini [17-Sep-2018 00:36:59] ERROR: [pool www] please specify user ...

  10. ArrayList源码及解析

    package java.util; import java.util.function.Consumer; import java.util.function.Predicate; import j ...