/* *检查路径是否存在 */function checkDir($dir){ exec("/bin/ls $dir", $info, $status); $sta = empty($info) ? $sta = 1 : $sta = 0;//1路径不存在,0路径存在 return $sta;} //仓库是git还是svnfunction warehouseCheck($warehouse){ if (preg_match("/.git$/i", $warehouse)) { $sta = 1; //1为git } if (preg_match("/^svn:\/\//i", $warehouse)) { $sta = 2; //2为svn } return $sta;} //环境选择function envCheck($env_name, $ser_tmp){ if (strpos($env_name, "测试") !== false) { $dir_tmp = "$ser_tmp/cs"; } elseif (strpos($env_name, "预发布") !== false) { $dir_tmp = "$ser_tmp/yfb"; } elseif (strpos($env_name, "正式") !== false || strpos($env_name, "线上") !== false) { $dir_tmp = "$ser_tmp/zs"; } else { $dir_tmp = ""; } return $dir_tmp;} //发邮件function sendMail($to, $subject, $content,$send_user){ header("content-type:text/html;charset=utf-8"); ini_set("magic_quotes_runtime",0); vendor("Phpmailer.phpmailer"); try { $mail = new PHPMailer(true);//实例化 $mail->IsSMTP();// 启用SMTP $mail->CharSet=‘UTF-8‘; //设置邮件的字符编码,这很重要,不然中文乱码 $mail->SMTPAuth = true; //开启认证 $mail->Port = 25; $mail->Host = "smtp.exmail.qq.com"; $mail->Username = "[email protected]"; $mail->Password = "feibo54321"; //$mail->IsSendmail(); //如果没有sendmail组件就注释掉,否则出现“Could not execute: /var/qmail/bin/sendmail ”的错误提示 //$mail->AddReplyTo("[email protected]","mckee");//回复地址 $mail->From = "[email protected]"; $mail->FromName = $send_user; //$to = "[email protected]"; //dump($to);die; foreach($to as $v){ $mail->AddAddress($v); } $content = str_replace(‘\n‘,"\n",$content); $mail->IsHTML(true); //支持html格式内容 $mail->Subject = $subject; $mail->Body = $content; //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //当邮件不支持html时备用显示,可以省略 $mail->WordWrap = 80; // 设置每行字符串的长度 //$mail->AddAttachment("f:/test.png"); //可以添加附件 $mail->Send(); } catch (phpmailerException $e) { echo "邮件发送失败:".$e->errorMessage(); }}
时间: 2024-10-10 07:42:30