20201112
This commit is contained in:
40
application/api/job/mail.php
Normal file
40
application/api/job/mail.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\job;
|
||||
|
||||
use think\queue\Job;
|
||||
|
||||
class mail {
|
||||
|
||||
//put your code here
|
||||
|
||||
public function fire(Job $job, $data) {
|
||||
$res = $this->send($data);
|
||||
if($res){
|
||||
$job->delete();
|
||||
}else{
|
||||
if($job->attempts()>3){
|
||||
// 第1种处理方式:重新发布任务,该任务延迟10秒后再执行
|
||||
//$job->release(10);
|
||||
// 第2种处理方式:原任务的基础上1分钟执行一次并增加尝试次数
|
||||
//$job->failed();
|
||||
// 第3种处理方式:删除任务
|
||||
$job->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件的逻辑
|
||||
* @param type $data
|
||||
*/
|
||||
public function send($data){
|
||||
$r = sendEmail($data['email'],$data['title'],$data['title'],$data['content'],$data['tmail'],$data['tpassword']);
|
||||
if($r['status']==1){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user