2 Star 2 Fork 4

Tody_Guo/php_issue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sendmail.php 3.01 KB
一键复制 编辑 原始数据 按行查看 历史
jiahui.guo 提交于 2020-12-21 18:37 . update
<?php
extract($_POST);
extract($_GET);
unset($_POST,$_GET);
function doAsyncMail($param=array()){
$urlinfo = parse_url('http://10.100.160.166/sendmail.php');
$host = $urlinfo['host'];
$path = $urlinfo['path'];
$query = isset($param)? http_build_query($param) : '';
$port = 80;
$errno = 0;
$errstr = '';
$timeout = 20;
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
stream_set_blocking($fp,true);//开启了手册上说的非阻塞模式
stream_set_timeout($fp,1);//设置超时
$out = "POST ".$path." HTTP/1.1\r\n";
$out .= "host:".$host."\r\n";
$out .= "content-length:".strlen($query)."\r\n";
$out .= "content-type:application/x-www-form-urlencoded\r\n";
$out .= "connection:close\r\n\r\n";
$out .= $query;
fputs($fp, $out);
usleep(1000); // 这一句也是关键,如果没有这延时,可能在nginx服务器上就无法执行成功
fclose($fp);
}
function SendMail($title, $Message, $to = "NONE"){
if(isset($to)){
switch($to){
case "TE":
$to = "A-TFS-ENG-EE-TE@hd.tongfangpc.com";
break;
case "SW":
$to = "A-TFS-SZSW@hd.tongfangpc.com;A-TFS-ENG-EE-TE@hd.tongfangpc.com";
break;
case "PT":
$to = "A-TFS-SZSW@hd.tongfangpc.com;A-TFS-RD-PT-PT@hd.tongfangpc.com;A-TFS-ENG-EE-TE@hd.tongfangpc.com";
break;
case "MFG":
$to = "qinglei.li@hd.tongfangpc.com;wei.hou@hd.tongfangpc.com;sword.zhu@hd.tongfangpc.com;bridge.sun@hd.tongfangpc.com;
qianghu.yin@hd.tongfangpc.com;Guoping.Zhou@hd.tongfangpc.com;Yingjuan.wang@hd.tongfangpc.com;
A-TFS-ENG-EE-TE@hd.tongfangpc.com";
break;
case "QA":
$to = "Qiangwei.Yin@hd.tongfangpc.com;Jiao.Yin@hd.tongfangpc.com;MQA04@hd.tongfangpc.com;hao.zhang@hd.tongfangpc.com;Sherry.Liu@hd.tongfangpc.com;
Yingjuan.wang@hd.tongfangpc.com;Guoping.Zhou@hd.tongfangpc.com;jinyan.huang@hd.tongfangpc.com;qiufang.dong@hd.tongfangpc.com;
yinlan.shao@hd.tongfangpc.com;Xin.Li@hd.tongfangpc.com;A-TFS-ENG-EE-TE@hd.tongfangpc.com";
//$to = "jiahui.guo@hd.tongfangpc.com";
break;
case "EE":
$to = "A-TFS-ENG-EE-EE@hd.tongfangpc.com;zhiyang.zhu@hd.tongfangpc.com";
//$to = "jiahui.guo@hd.tongfangpc.com";
break;
default:
//$to = "jiahui.guo@hd.tongfangpc.com;Qiuqin.Jiang@hd.tongfangpc.com"; //sendmail测试邮件发送到的地址
$to = "jiahui.guo@hd.tongfangpc.com"; //sendmail测试邮件发送到的地址
break;
}
}
$headers = "X-Mailer:PHP\n";
$headers.= "MIME-Version: 1.0\n";
$headers.= "Content-type:text/html;charset=utf-8\n";
$headers.= "X-Priority: 1\n";
$headers.= "From: TE_KS<TE_KS@hd.tongfangpc.com>\r\n";
$message = "<html><head><meta charset='utf-8'></head><body>${Message}</body></html>";
$subject = "${title}";
$message=wordwrap($message, 70);
if (mail($to, $subject, $message, $headers)) {
echo "邮件发送成功!";
} else {
echo "邮件发送失败!";
}
}
// here to check if there is a async message sent
if(isset($aSync)){
SendMail($title, $msg, $to);
}
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/tody_guo/php_issue.git
git@gitee.com:tody_guo/php_issue.git
tody_guo
php_issue
php_issue
master

搜索帮助