正在显示
1 个修改的文件
包含
52 行增加
和
0 行删除
| @@ -154,6 +154,52 @@ class MailFun { | @@ -154,6 +154,52 @@ class MailFun { | ||
| 154 | 154 | ||
| 155 | 155 | ||
| 156 | /** | 156 | /** |
| 157 | + * 验证是否发送或接收预热邮件 | ||
| 158 | + * @param $from | ||
| 159 | + * @param $tos | ||
| 160 | + * @author:dc | ||
| 161 | + * @time 2026/11/3 15:36 | ||
| 162 | + */ | ||
| 163 | + public static function isSendHotMail($from, $tos=[]) | ||
| 164 | + { | ||
| 165 | + // 国内营销项目 postid(与 fob_hot_ai_mail_auto_reply「国内项目不回复」保持一致) | ||
| 166 | + $domesticPostids = [10001746, 10002367]; | ||
| 167 | + | ||
| 168 | + // 预热发送:发件邮箱 或 收件人 任一属于国内营销项目即拦截 | ||
| 169 | + // ① 发件邮箱 | ||
| 170 | + $isDomesticSender = (bool) fob_mysql()->cache(3600)->value( | ||
| 171 | + "select `post_id` from `e_mail_binds` where `email` = '" . $from | ||
| 172 | + . "' and `post_id` in (" . implode(',', $domesticPostids) . ") limit 1" | ||
| 173 | + ); | ||
| 174 | + // 发件是国内 | ||
| 175 | + if($isDomesticSender){ | ||
| 176 | + $isDomesticRecipient = (bool) fob_mysql()->cache(3600)->value( | ||
| 177 | + "select `post_id` from `e_mail_binds` where `email` in ('" | ||
| 178 | + . implode("','", array_map('addslashes', $tos)) | ||
| 179 | + . "') limit 1" | ||
| 180 | + ); | ||
| 181 | + if($isDomesticRecipient){ | ||
| 182 | + return true; | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + // 发件不是国内 | ||
| 186 | + else{ | ||
| 187 | + $isDomesticRecipient = (bool) fob_mysql()->cache(3600)->value( | ||
| 188 | + "select `post_id` from `e_mail_binds` where `email` in ('" | ||
| 189 | + . implode("','", array_map('addslashes', $tos)) | ||
| 190 | + . "') and `post_id` in (" . implode(',', $domesticPostids) . ") limit 1" | ||
| 191 | + ); | ||
| 192 | + if($isDomesticRecipient){ | ||
| 193 | + return true; | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + | ||
| 198 | + return false; | ||
| 199 | + | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 157 | * 发送邮件 | 203 | * 发送邮件 |
| 158 | * @param array $data 数据 | 204 | * @param array $data 数据 |
| 159 | * @param array $email 邮箱信息 | 205 | * @param array $email 邮箱信息 |
| @@ -164,6 +210,12 @@ class MailFun { | @@ -164,6 +210,12 @@ class MailFun { | ||
| 164 | * @time 2023/4/11 9:12 | 210 | * @time 2023/4/11 9:12 |
| 165 | */ | 211 | */ |
| 166 | public static function sendEmail(array $data, array $email,$debug = false){ | 212 | public static function sendEmail(array $data, array $email,$debug = false){ |
| 213 | + | ||
| 214 | + // 特定的预热项目不发 | ||
| 215 | + if(self::isSendHotMail($email['email'],array_column($data['tos'],'email'))){ | ||
| 216 | + return [false, '当前项目不可发送/接收预热邮件']; | ||
| 217 | + } | ||
| 218 | + | ||
| 167 | $smtp = self::getHostPort($email['smtp'],465); | 219 | $smtp = self::getHostPort($email['smtp'],465); |
| 168 | // 邮件对象 | 220 | // 邮件对象 |
| 169 | $mail = new PHPMailer(); | 221 | $mail = new PHPMailer(); |
-
请 注册 或 登录 后发表评论