|
|
@@ -218,7 +218,7 @@ class MailHelper
|
|
|
$connection=Yii::$app->db;
|
|
|
$time = time() - 300;
|
|
|
//将5分钟内发送给相同收件人和相同主题的发件记录设置为不可发送状态
|
|
|
- $sql = "update crm_mail_record set status = 2 where subject = '$subject' and receiver = $to and in_time > $time";
|
|
|
+ $sql = "update crm_mail_record set status = 2 where subject = '$subject' and receiver = '$to' and in_time > $time";
|
|
|
$command=$connection->createCommand($sql);
|
|
|
$rowCount=$command->execute();
|
|
|
}else{
|
|
|
@@ -394,22 +394,28 @@ class MailHelper
|
|
|
$connection=Yii::$app->db;
|
|
|
$time = time() - 300;
|
|
|
//将5分钟内发送给相同收件人和相同主题的发件记录设置为不可发送状态
|
|
|
- $sql = "update crm_mail_record set status = 2 where subject = '$subject' and receiver = $to and in_time > $time";
|
|
|
+ $sql = "update crm_mail_record set status = 2 where subject = '$subject' and receiver = '$to' and in_time > $time";
|
|
|
$command=$connection->createCommand($sql);
|
|
|
$rowCount=$command->execute();
|
|
|
return false;
|
|
|
}else{
|
|
|
+ $transport = [
|
|
|
+ 'class' => 'Swift_SmtpTransport',
|
|
|
+ 'host' => $configArr['host'],
|
|
|
+ 'username' => $configArr['smtp_username'],
|
|
|
+ 'password' => $configArr['password'],
|
|
|
+ 'port' => $configArr['port'],
|
|
|
+ 'encryption' => 'ssl',
|
|
|
+ ];
|
|
|
+ if($configArr['port'] == 587){
|
|
|
+ $transport['encryption'] = 'tls';
|
|
|
+ }else{
|
|
|
+ $transport['encryption'] = 'ssl';
|
|
|
+ }
|
|
|
Yii::$app->set('mailer', [
|
|
|
'class' => 'yii\swiftmailer\Mailer',
|
|
|
'useFileTransport' => false,
|
|
|
- 'transport' => [
|
|
|
- 'class' => 'Swift_SmtpTransport',
|
|
|
- 'host' => $configArr['host'],
|
|
|
- 'username' => $configArr['smtp_username'],
|
|
|
- 'password' => $configArr['password'],
|
|
|
- 'port' => $configArr['port'],
|
|
|
- 'encryption' => 'ssl',
|
|
|
- ],
|
|
|
+ 'transport' => $transport,
|
|
|
'messageConfig' => [
|
|
|
'charset' => 'UTF-8',
|
|
|
'from' => [$configArr['send_mail'] => 'Vegard']
|