作者 邓超

预热屏蔽

... ... @@ -154,6 +154,52 @@ class MailFun {
/**
* 验证是否发送或接收预热邮件
* @param $from
* @param $tos
* @author:dc
* @time 2026/11/3 15:36
*/
public static function isSendHotMail($from, $tos=[])
{
// 国内营销项目 postid(与 fob_hot_ai_mail_auto_reply「国内项目不回复」保持一致)
$domesticPostids = [10001746, 10002367];
// 预热发送:发件邮箱 或 收件人 任一属于国内营销项目即拦截
// ① 发件邮箱
$isDomesticSender = (bool) fob_mysql()->cache(3600)->value(
"select `post_id` from `e_mail_binds` where `email` = '" . $from
. "' and `post_id` in (" . implode(',', $domesticPostids) . ") limit 1"
);
// 发件是国内
if($isDomesticSender){
$isDomesticRecipient = (bool) fob_mysql()->cache(3600)->value(
"select `post_id` from `e_mail_binds` where `email` in ('"
. implode("','", array_map('addslashes', $tos))
. "') limit 1"
);
if($isDomesticRecipient){
return true;
}
}
// 发件不是国内
else{
$isDomesticRecipient = (bool) fob_mysql()->cache(3600)->value(
"select `post_id` from `e_mail_binds` where `email` in ('"
. implode("','", array_map('addslashes', $tos))
. "') and `post_id` in (" . implode(',', $domesticPostids) . ") limit 1"
);
if($isDomesticRecipient){
return true;
}
}
return false;
}
/**
* 发送邮件
* @param array $data 数据
* @param array $email 邮箱信息
... ... @@ -164,6 +210,12 @@ class MailFun {
* @time 2023/4/11 9:12
*/
public static function sendEmail(array $data, array $email,$debug = false){
// 特定的预热项目不发
if(self::isSendHotMail($email['email'],array_column($data['tos'],'email'))){
return [false, '当前项目不可发送/接收预热邮件'];
}
$smtp = self::getHostPort($email['smtp'],465);
// 邮件对象
$mail = new PHPMailer();
... ...