*/
header('Content-type:text/html;charset=utf-8');
include './smtp/class.smtp.php';
include './smtp/class.phpmailer.php';
function sendmail($subject = '',$body = '') {
date_default_timezone_set('Asia/Shanghai');//设定时区东八区
$mail = new PHPMailer(); //new一个PHPMailer对象出来
// $body = eregi_replace("[]",'',$body); //对邮件内容进行必要的过滤
$mail->CharSet ="UTF-8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP(); // 设定使用SMTP服务
$mail->SMTPAuth = true; // 启用 SMTP 验证功能
$mail->Host = 'smtp.exmail.qq.com'; // SMTP 服务器
$mail->Port = 25; // SMTP服务器的端口号
$mail->Username = '[email protected]'; // SMTP服务器用户名
$mail->Password = 'password'; // SMTP服务器密码
$mail->SetFrom('[email protected]','Status');
$mail->AddReplyTo('[email protected]','Status');
$mail->Subject = $subject;
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional, comment out and test
$mail->MsgHTML($body);
$address = '[email protected]'; //接收邮箱
$mail->AddAddress($address, '');
//$mail->AddAttachment("images/phpmailer.gif"); // attachment 附件
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
// echo "Message sent!恭喜,邮件发送成功!";
}
}
//check server status
function checkServerSatatus($ip) {
$str = null;
$fp = @fsockopen($ip,80,$errno,$errstr,10);
if (!$fp) {
return false;
} else {
fclose($fp);
return true;
}
}
$server_ip_list = array(
'61.135.169.121',
'221.204.173.200',
'173.194.127.83'
);
?>
服务器状态监控
服务器在线状态监控
IDLocationAddressStatus
$i++;
if (checkServerSatatus($server_ip_list[$key])) {
echo "
{$i}{$result->country}{$result->region}{$result->city}{$server_ip_list[$key]}在线";
} else {
echo "
{$i}{$result->country}{$result->region}{$result->city}{$server_ip_list[$key]}不在线";
$subject = "您的服务器 {$server_ip_list[$key]} 无法访问!";
$body = "您的服务器{$server_ip_list[$key]} 无法访问,此邮件根据你设置的监控频率发送,当服务器恢复正常邮件自动停止发送!";
sendmail($subject,$body);
}
}
?>