git的push邮件简单通知钩子

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

代码在下面:

<?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 = "[email protected]";
$mail->Password = "xxxxxx";

$mail->From = "[email protected]";
$mail->FromName = "海棠姐姐";

$mail->Subject = "一个新的Push";
$mail->Body = $mailBody;
$mail->IsHTML(true);
$mail->AddAddress("[email protected]", "海棠姐姐");
$mail->AddAddress("[email protected]", "傻逼O");

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


效果图:

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

8 Replies to “git的push邮件简单通知钩子”

发表回复

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

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据