Answer the question
In order to leave comments, you need to log in
Why is Swift_TransportException not being caught in queue\JobInterface?
In console.php config:
'mailer' => [
'class' => \yii\swiftmailer\Mailer::class,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'mail.mymail.test',
'username' => getenv('YII_MAILER_USER'),
'password' => getenv('YII_MAILER_PASSWORD'),
'port' => '587',
'encryption' => 'tls',
],
'useFileTransport' => false,
],
try {
Yii::$app->mailer->compose()
->setFrom('i[email protected]')
->setTo('[email protected]_mail_domain.test')
->setSubject('test')
->send();
}
catch (\Swift_TransportException $e) {
$mailed_status = 'ERROR';
$_mailed_to['error'] = $e->getMessage();
}
yii queue/listen --verbose=1 --color=1 --isolate=0
yii queue/listen --verbose=1 --color=1
[email protected]:/var/www/html# /var/www/irp/yii queue/listen --verbose=1 --color=1
2021-08-26 10:30:10 [pid: 94] - Worker is started
2021-08-26 10:30:17 [890] app\modules\system\queue\QueueJobThreatMailing (attempt: 1, pid: 94) - Started
2021-08-26 10:30:20 [890] app\modules\system\queue\QueueJobThreatMailing (attempt: 1, pid: 94) - Error (2.586 s)
> Swift_TransportException: Expected response code 250 but got code "503", with message "503 5.5.1 Error: nested MAIL command
try {
throw new Exception('Exception!!!');
}
catch (Exception $e) {
echo 'Exception has catched: ' . $e->getMessage() . PHP_EOL;
}
2021-08-26 12:18:22 [pid: 116] - Worker is started
2021-08-26 12:18:29 [898] app\modules\system\queue\QueueJobThreatMailing (attempt: 1, pid: 116) - Started
Exception has catched: Exception!!!
2021-08-26 12:18:30 [898] app\modules\system\queue\QueueJobThreatMailing (attempt: 1, pid: 116) - Done (0.254 s)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question