Intermittent Email Send Failure |
I have a strange one where sending emails fails intermittently.
The application uses CI4 email class connecting via SMTP (SSL on 465). I have written a mail queuing system that gets executed every 5 min (via cron job) to send the emails in the que. If successful the entry is deleted from the que else the retry counter gets incremented and the email stays in the que. The problem is that a number of emails are processed and sent and then the next number of emails fails to send. Then when the cron is triggered again the emails that failed are sent and the cycle continues. The latest batch 6 emails were sent and 8 failed, 5 minutes later 4 were sent and 4 failed and then 5min later the last 4 in the batch were sent. When the emails fail the server responds with "Failed to send AUTH LOGIN command. Error: 221 server1.abatrans-rsahub.co.za closing connection". When I examined the Exim log, it shows that the connection was opened, waits for about 5 seconds and then close the connection. I have had a ding-dong with the hosting provider but they blame the app. If anybody have any ideas please help. To give an idea of how frustrating this is, last week the client set a notice to some of their client, 762 emails were qued, it took 19000 attempts to send the all the email. Environment Server: Centos 7 using Exim 4.95 SMTP mail server. Application: CodeIgniter 4.1.9 PHP 7.4
Well without see your email code it is hard to help find a solution to your problem.
One thing is make sure you do an email clear after sending, you may also need to set the email configuration after that. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Extract of code that formats and send the emails
PHP Code: $mode = getOption( 'email_mode' ); ////// EMail Config as set in .env Code: email.userAgent = 'System Name' All other Email variables are CI default.
CodeIgniter 4 User Guide - Email Preferences
SMTP Port. (If set to 465, TLS will be used for the connection regardless of SMTPCrypto setting.) Not sure if that is your problem. Make sure you do the email clear in your foreach loop for emails. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |