...
|
...
|
@@ -10,6 +10,7 @@ use Model\bodySql; |
|
|
use Model\emailSql;
|
|
|
use Model\folderSql;
|
|
|
use Model\listsSql;
|
|
|
use Model\sendJobsSql;
|
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
|
|
...
|
...
|
@@ -228,9 +229,19 @@ class Home extends Base { |
|
|
$sendData['priority'] = $formData['priority']??3;// 是否紧急邮件
|
|
|
$sendData['subject'] = $formData['subject'];// //Content 主题,标题
|
|
|
$sendData['body'] = $formData['body'];
|
|
|
// 不重要的信息
|
|
|
$sendData['jobName'] = $formData['jobName']??'';//任务标题
|
|
|
$sendData['massSuit'] = $formData['massSuit']??0;// 是否是群发单显
|
|
|
|
|
|
// 定时发送时间
|
|
|
$timer = strtotime(app()->request('timerValue','2023-04-10'));
|
|
|
$timer = app()->request('timerValue',0);
|
|
|
if(is_numeric($timer) && $timer){
|
|
|
$timer = time()+$timer;
|
|
|
}else if (is_string($timer)){
|
|
|
$timer = strtotime($timer);
|
|
|
}else{
|
|
|
$timer = 0;
|
|
|
}
|
|
|
// 是否存草稿
|
|
|
if(app()->request('saveType')=='draft'){
|
|
|
// 保存
|
...
|
...
|
@@ -242,15 +253,37 @@ class Home extends Base { |
|
|
app()->e('save_draft_error');
|
|
|
|
|
|
}
|
|
|
// 定时发送
|
|
|
else if(app()->request('timer') && $timer > time()){
|
|
|
// 定时发送 或者是单条发送
|
|
|
else if((app()->request('timer') && $timer > time()) || $sendData['massSuit']){
|
|
|
|
|
|
}else{
|
|
|
// 发送
|
|
|
// $result = MailFun::sendEmail($sendData,$email);
|
|
|
// if($result[0]){
|
|
|
// app()->_json(['messageId' => $result[1]]);
|
|
|
// }
|
|
|
if($sendData['massSuit']){
|
|
|
// 每次发送间隔的时间
|
|
|
$sendData['masssuit_interval_send'] = app()->request('masssuit_interval_send');
|
|
|
$sendData['masssuit_interval_send']['start'] = intval($sendData['masssuit_interval_send']['start']??0);
|
|
|
$sendData['masssuit_interval_send']['end'] = intval($sendData['masssuit_interval_send']['end']??1);
|
|
|
}
|
|
|
|
|
|
// 插入任务
|
|
|
$job_id = db()->insert(sendJobsSql::$table,[
|
|
|
'email_id' => $email['id'],
|
|
|
'maildata' => $sendData,
|
|
|
'title' => $sendData['jobName'] ? : $sendData['subject'],
|
|
|
'total' => count($sendData['tos']),
|
|
|
'send_time' => $timer
|
|
|
]);
|
|
|
if($job_id){
|
|
|
// 返回任务id
|
|
|
app()->_json(['job_id'=>$job_id]);
|
|
|
}
|
|
|
|
|
|
app()->e('send_timer_job_error');
|
|
|
}
|
|
|
else{
|
|
|
// 立即发送
|
|
|
$result = MailFun::sendEmail($sendData,$email);
|
|
|
if($result[0]){
|
|
|
app()->_json(['messageId' => $result[1]]);
|
|
|
}
|
|
|
// 错误
|
|
|
app()->e($result[1]);
|
|
|
}
|
...
|
...
|
@@ -490,7 +523,9 @@ class Home extends Base { |
|
|
|
|
|
if($data){
|
|
|
$sync_num = 0;
|
|
|
$data['to_name'] = json_decode($data['to_name']??"[]",true);
|
|
|
$data['to_name'] = $data['to_name'] ? json_decode($data['to_name'],true) : [];
|
|
|
$data['cc'] = $data['cc'] ? json_decode($data['cc'],true) : [];
|
|
|
$data['bcc'] = $data['bcc'] ? json_decode($data['bcc'],true) : [];
|
|
|
|
|
|
HOME_INFO_BODY:
|
|
|
$body = db()->first(bodySql::first($id));
|
...
|
...
|
@@ -551,9 +586,15 @@ class Home extends Base { |
|
|
return [
|
|
|
'data' => $data
|
|
|
];
|
|
|
}// 草稿
|
|
|
else if(!$data['uid'] && $data['draft']){
|
|
|
$data['body'] = [];
|
|
|
return [
|
|
|
'data' => $data
|
|
|
];
|
|
|
}
|
|
|
// 循环几次
|
|
|
if($sync_num < 1){
|
|
|
if($data['uid']&&$sync_num < 1){
|
|
|
$mail = new Mail($email['email'],base64_decode($email['password']),$email['imap']);
|
|
|
|
|
|
if($mail->login()){
|
...
|
...
|
|