0
votes

We've been using PHPMailer to send SMTP mail through Mailgun for years now.

We've recently upgraded our logging, and we've noticed that some mail just doesn't send.

Here is the SMTP log we're seeing:

Connection: opening to smtp.mailgun.org:587, timeout=300, options=array()
Connection: opened
SERVER -> CLIENT: SMTP
NOTICE: EOF caught while checking if connected
Connection: closed
SMTP Error: Could not connect to SMTP host.
SMTP Error: Could not connect to SMTP host.

This particular email was attempted to be sent with the Start TLS method via port 587.

How come most of our mail gets through but now and then we get this error? Does anyone know what "EOF caught while checking if connected" could be caused by?

We're using the latest stable build of PHPMailer v6.1.5.

Thanks!

1
That sounds like aborted connection. It is a random error you spot now and then or something 100% reproducible? - Álvaro González
Looks like mailgun is dropping the connection – PHPMailer can only work with what it's given, so I'd recommend catching the error and retrying. - Synchro
@ÁlvaroGonzález It's seemingly random, I just picked one email up and resent it and this time it sent perfectly fine. - bbeckford
Yes, and perhaps ask Mailgun about it - Synchro
Occasional connectivity issues are something to be expected. I wouldn't give them too much importance as long as they aren't too common. Just make sure you app handles them gracefully (i.e., detect the message wasn't sent and enable a mechanism to retry later). - Álvaro González

1 Answers

0
votes

Thanks to advice from @Syncro and @Álvaro González and Mailgun themselves, I ended up building in a retry mechanism that attempts to send mail 3 times before failing.

So far this seems to be working, I will report back if anything changes!