stevepatd Posted Thursday at 03:48 AM Share Posted Thursday at 03:48 AM I just updated PHPMailer from version 5.1 to 6.10.0. I was successfully sending small batches of emails today, so I thought everything was great. Tonight I went to run a job that was going to send a couple thousand emails out and it stopped about a third of the way through. It just stopped sending out emails after about 369 emails. I started it again from the point where it quit and it only made it through the next 500ish. After starting from that spot it made it through the list. There are no errors messages, no error logs, no debugging logs. I never had anything like this happen when running v5.1. Nothing else changed in my code, data files, etc. So I am wondering if there is some limiting factor with the newer PHPMailer? Does it take more memory? I'm looking for ideas on how to debug this. Any relevant differences between PHPMailer 5.1 and 6.10.0? Suggestions how I should debug it? Other than the first 4 lines of code below, nothing has changed. I find it hard to believe it is a code issue since this has been running for many years without issue. Ideas where I should start? require_once 'include_files/PHPMailer/PHPMailer_v6.10.0/PHPMailer/Exception.php'; require_once 'include_files/PHPMailer/PHPMailer_v6.10.0/PHPMailer/PHPMailer.php'; require_once 'include_files/PHPMailer/PHPMailer_v6.10.0/PHPMailer/SMTP.php'; $mailer = new PHPMailer\PHPMailer\PHPMailer(true); $mailer -> IsSMTP(); $mailer -> Host = 'smtp.mandrillapp.com'; $mailer -> SMTPAuth = true; $mailer -> Username = 'myusername'; $mailer -> Password = 'mypassword'; $mailer -> SMTPSecure = 'tls'; $mailer -> Port = 587; $mailer -> IsHTML(true); $mailer -> AddReplyTo('My Email'); $mailer -> FromName = "My Name"; $mailer -> From = 'My Email'; $mailer -> AddAddress('Your Email'); $mailer -> Subject = 'My Subject'; $mailer -> Body = 'My Message'; if ($mailer -> Send()) { } else { print "Mailer Error: " . $mailer->ErrorInfo; } Quote Link to comment https://forums.phpfreaks.com/topic/330186-phpmailer-stops-sending-out-emails/ Share on other sites More sharing options...
mac_gyver Posted Thursday at 07:46 AM Share Posted Thursday at 07:46 AM how are you invoking this? is the code looping over data, and if so what is the code with the looping? approximately how long was the execution time for each of the segments of sent emails? you are using exceptions for errors. when using exceptions, none of the discrete error checking logic will ever get executed upon an error and should be removed. when using exceptions for errors, unless you are doing something special with the error information, you should not catch and handle exceptions in your code. instead let php catch and handle any exception, where php will use its error related settings (error_reporting, display_errors, and log_errors) to control what happens with the actual error information, via an uncaught exception error. php's error_reporting should always be set to E_ALL. if you are invoking this via a browser, you should set display_errors to ON, so that any php detected errors (which will include any uncaught exceptions) will be displayed. if you are invoking this via a cron job/scheduled task, you should set log_errors to ON, so that any php detected errors will be logged. 1 Quote Link to comment https://forums.phpfreaks.com/topic/330186-phpmailer-stops-sending-out-emails/#findComment-1658218 Share on other sites More sharing options...
gizmola Posted 4 hours ago Share Posted 4 hours ago Beyond mac's insights and salient comments, the code snippet you provided tells us nothing, as it is not the code you are using. The only way to gain insight into this is having detailed logging to review when the mailer freezes. I'd also suggest scanning the release notes in regards to the phpMailer releases, to check if there are any Breaking changes you might have missed, or things that are now handled differently between the two versions. There are 2 likely possibilities based on your comments: There are some emails that are causing issues when delivered. The way the code is written (and the environment involved) uses up available resources (network connections, database handles, or other available memory). Many companies use phpMailer so I am doubtful that there is an issue with it that would be trivially obvious, but regardless of that, you need detailed debugging which will be best facilitated by the injection of an object that implements PSR3 as described in the phpMailer source code here. If you don't already have that, here's a bit more on setting that up: After the instantiation of the PHPMailer object, that would involve a call like this: $mail->Debugoutput = new myPsr3Logger; A lot of projects use the well regarded monolog library which allows for logging to be integrated into many different logging systems, but in your case, just insuring it is writing to a log file on your system would be sufficient. As for some trivia, the author of monolog is the same guy who created PHP's dependency management tool Composer. The documentation states that the only log level that will be used is the 'Debug' level. Quote Link to comment https://forums.phpfreaks.com/topic/330186-phpmailer-stops-sending-out-emails/#findComment-1658784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.