git的push邮件简单通知钩子

坑爹,代码高亮不能用了,发个编辑器的截图好了,哈哈哈

20140620224446

 

代码在下面:

<?php
$jsonObj = json_decode($_POST[‘hook’]);
if ($jsonObj->password != ‘HIUBb7679bON50OBOtfwq78’) {
exit(‘error pwd!’);
}

$mailBody = $jsonObj->push_data->user_name.”提交了新的代码<br>”.”项目名称:”.$jsonObj->push_data->repository->name.”<br>”.
‘项目首页:<a href=”‘.$jsonObj->push_data->repository->homepage.'”>’.$jsonObj->push_data->repository->homepage.'<a><br>’.
“提交时间:”.$jsonObj->push_data->commits[0]->timestamp.'<br><a href=”‘.$jsonObj->push_data->commits[0]->url.'”>’.
$jsonObj->push_data->commits[0]->url.'<a>’;

include(“class.phpmailer.php”);
$mail= new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = “ssl”;
$mail->Host = “smtp.qq.com”;
$mail->Port = 465;
$mail->CharSet = “utf-8”;
$mail->Username = “admin@myluoluo.com”;
$mail->Password = “xxxxxx”;

$mail->From = “admin@myluoluo.com”;
$mail->FromName = “海棠姐姐”;

$mail->Subject = “一个新的Push”;
$mail->Body = $mailBody;
$mail->IsHTML(true);
$mail->AddAddress(“admin@myluoluo.com”, “海棠姐姐”);
$mail->AddAddress(“o@moe.re”, “傻逼O”);

if(!$mail->Send()) {
echo “Mailer Error: ” . $mail->ErrorInfo;
} else {
echo “Message sent!”;
}
?>

效果图:

 

 

恩,确实很简单,哈哈哈哈

“git的push邮件简单通知钩子”的8个回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注