|
@@ -239,6 +239,16 @@ class MailFun { |
|
@@ -239,6 +239,16 @@ class MailFun { |
239
|
$mail->Subject = $data['subject'];
|
239
|
$mail->Subject = $data['subject'];
|
240
|
|
240
|
|
241
|
$mail->isHTML(true); //Set email format to HTML
|
241
|
$mail->isHTML(true); //Set email format to HTML
|
|
|
242
|
+
|
|
|
243
|
+ // todo:: 订阅功能只可用作单发,不可群发。否则无法验证订阅人
|
|
|
244
|
+ if(count($mail->getToAddresses()) == 1){
|
|
|
245
|
+ $data['body'] = str_replace(
|
|
|
246
|
+ ['{#subscribe_uuid#}','%7B%23subscribe_uuid%23%7D'], // 订阅用的key 获取用户信息所用
|
|
|
247
|
+ self::enSubscribeUrl($mail->Username,$mail->getToAddresses()[0][0]??'',$mail->Subject),
|
|
|
248
|
+ $data['body']
|
|
|
249
|
+ );
|
|
|
250
|
+ }
|
|
|
251
|
+
|
242
|
$mail->Body = $data['body'];// html格式的内容
|
252
|
$mail->Body = $data['body'];// html格式的内容
|
243
|
|
253
|
|
244
|
// 发送
|
254
|
// 发送
|
|
@@ -344,4 +354,57 @@ class MailFun { |
|
@@ -344,4 +354,57 @@ class MailFun { |
344
|
}
|
354
|
}
|
345
|
|
355
|
|
346
|
|
356
|
|
|
|
357
|
+
|
|
|
358
|
+
|
|
|
359
|
+
|
|
|
360
|
+
|
|
|
361
|
+ /**
|
|
|
362
|
+ * 生成订阅按钮
|
|
|
363
|
+ * @param string $from_email 发件人
|
|
|
364
|
+ * @param string $to_email 收件人
|
|
|
365
|
+ * @return string
|
|
|
366
|
+ * @author:dc
|
|
|
367
|
+ * @time 2024/8/7 10:56
|
|
|
368
|
+ */
|
|
|
369
|
+ public static function enSubscribeUrl(string $from_email,string $to_email,string $subject=''){
|
|
|
370
|
+ $params = [
|
|
|
371
|
+ 'from' => $from_email,
|
|
|
372
|
+ 'to' => $to_email,
|
|
|
373
|
+ 'subject' => $subject,
|
|
|
374
|
+ ];
|
|
|
375
|
+
|
|
|
376
|
+ $params = json_encode($params);
|
|
|
377
|
+
|
|
|
378
|
+ return md5($from_email.'-'.$to_email.'-aicc')."+".trim(base64_encode($params),'=');
|
|
|
379
|
+ }
|
|
|
380
|
+
|
|
|
381
|
+ /**
|
|
|
382
|
+ * 解析url中的数据
|
|
|
383
|
+ * @param string $url
|
|
|
384
|
+ * @author:dc
|
|
|
385
|
+ * @time 2024/8/7 11:49
|
|
|
386
|
+ */
|
|
|
387
|
+ public static function deSubscribeUrl(string $url){
|
|
|
388
|
+ list($sign,$params) = explode('+',$url);
|
|
|
389
|
+
|
|
|
390
|
+ if(!$sign || strlen($sign)!=32 || !$params){
|
|
|
391
|
+ return [];
|
|
|
392
|
+ }
|
|
|
393
|
+
|
|
|
394
|
+ $params = base64_decode($params.'==');
|
|
|
395
|
+ $params = @json_decode($params,true);
|
|
|
396
|
+
|
|
|
397
|
+ if(!$params){
|
|
|
398
|
+ return [];
|
|
|
399
|
+ }
|
|
|
400
|
+
|
|
|
401
|
+ if($sign != md5($params['from'].'-'.$params['to'].'-aicc')){
|
|
|
402
|
+ return [];
|
|
|
403
|
+ }
|
|
|
404
|
+
|
|
|
405
|
+ return $params;
|
|
|
406
|
+ }
|
|
|
407
|
+
|
|
|
408
|
+
|
|
|
409
|
+
|
347
|
} |
410
|
} |