邮件消息队列修改
This commit is contained in:
@@ -796,7 +796,8 @@ class Article extends Controller {
|
||||
$tts .= 'Sincerely,<br>Editorial Office<br>'.$journal_info['title'].'<br>';
|
||||
$tts .= 'Email: '.$journal_info['email'].'<br>';
|
||||
$tts .= 'Website:<a href="'.$journal_info['website'].'">'.$journal_info['website'].'</a>';
|
||||
|
||||
$sendUser['user_id'] = $v['user_id'];
|
||||
$sendUser['email'] = $v['email'];
|
||||
$sendUser['content'] = $tts;
|
||||
Queue::push('app\api\job\domail@fire',$sendUser,'domail');
|
||||
// sendEmail($v['email'], $journal_info['title'], $journal_info['title'], $tts, $journal_info['email'], $journal_info['epassword']);
|
||||
|
||||
@@ -8,13 +8,65 @@ use think\queue\Job;
|
||||
|
||||
class domail {
|
||||
|
||||
|
||||
public function fire(Job $job, $data) {
|
||||
$this->send($data);
|
||||
// $this->send($data);
|
||||
// $job->delete();
|
||||
|
||||
// 发送邮件
|
||||
$isJobDone = $this->doTask($data);
|
||||
// 删除
|
||||
$job->delete();
|
||||
|
||||
//入库
|
||||
$this->insertData($data,$isJobDone);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function doTask($data){
|
||||
if(isset($data['attachment_url']) && !empty($data['attachment_url']) ){
|
||||
$res = sendEmail($data['email'],$data['title'],$data['from_name'],$data['content'],$data['sendEmail'],$data['sendPassword'],$data['attachment_url']);
|
||||
}else{
|
||||
$res = sendEmail($data['email'],$data['title'],$data['from_name'],$data['content'],$data['sendEmail'],$data['sendPassword']);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* email记录入库
|
||||
* @param $data
|
||||
* @param $isJobDone
|
||||
*/
|
||||
public function insertData($data,$isJobDone)
|
||||
{
|
||||
$insert = [
|
||||
'title' => $data['title'],
|
||||
'content' => $data['content'],
|
||||
'recive_id' => $data['user_id'],
|
||||
'recive_email' => $data['email'],
|
||||
'journal_id' => $data['journal_id'],
|
||||
'journal_email' => $data['sendEmail'],
|
||||
'journal_password' => $data['sendPassword'],
|
||||
'create_time' => time()
|
||||
];
|
||||
if (isset($data['attachment_url']) && !empty($data['attachment_url'])) {
|
||||
$insert['is_attachment'] = 1;
|
||||
$insert['attachment_url'] = $data['attachment_url'];
|
||||
}
|
||||
if($isJobDone['status']==0){
|
||||
$insert['is_success'] = 0;
|
||||
$insert['fail_reason'] = $isJobDone['data'];
|
||||
}
|
||||
Db::name('email')->insert($insert);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发送邮件的逻辑
|
||||
* @param type $data
|
||||
@@ -49,4 +101,5 @@ class domail {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user