Welcome Guest, Not a member yet? Register   Sign In
Intermittent Email Send Failure
#1

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
Dirk B.
Abatrans Software
No SEO spam - see forum guidelines
Reply
#2

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 )
Reply
#3

Extract of code that formats and send the emails

PHP Code:
    $mode    getOption'email_mode' );
    $email  Services::email();
    $email->clearTRUE );

/* Block of code creating html email body */

    $email->setTo( ( $mode !== 'SANDBOX' ) ? $mailto '[email protected]);
    if ( !empty( $mailCC ) ) {
        $email->setCC$mailCC );
    }
    $email->setSubject$subject );
    $email->setMessage$theMessage );
    $email->setReplyTo'[email protected]''System Name' );
    $email->setFrom'[email protected]''System Name' );
    foreach ( $attachments as $attachment ) {
        $email->attach$attachment );
    }
    $email->setNewline"\r\n" );

    $return'status' ]  $email->sendFALSE );

    if ( !$return'status' ] ) {
        $return'message' ]            $email->printDebugger();
        $emailRecord'reason_failed' ] = $return'message' ];
    }

// Write email record to log
// return $return 

//////
EMail Config as set in .env


Code:
email.userAgent = 'System Name'
email.protocol  = 'smtp'
email.SMTPHost  = 'mail.acme.co.za'
email.SMTPUser  = '[email protected]'
email.SMTPPass  = 'the password'
email.SMTPPort  = '465'
email.SMTPCrypto = 'ssl'
email.mailType = 'html'


All other Email variables are CI default.
Dirk B.
Abatrans Software
No SEO spam - see forum guidelines
Reply
#4

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 )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB