Jump to content

PHPMailer capturing errors bettter


MidOhioIT

Recommended Posts

Does anyone know if there is a good way to capture errors like a SMTP timed out or a mysql timeout?  I have a newsletter system that is fairly large (50,00 plus) and there are times where the server may have a hiccup or something and it would be nice if the code would catch the timeout, sleep for a minute and retry again instead of me keep checking and noticing that it stopped over an hour later..

I am just doing the standard:

 
require_once ('class.phpmailer.php');
    // read the database and get the emails..


	   $mail = new PHPMailer();

	$mail->IsSMTP();                                   // send via SMTP
	$mail->Host     = "localhost"; // SMTP servers
	$mail->SMTPAuth = true;     // turn on SMTP authentication

Link to comment
Share on other sites

You could experiment with try{}catch{} blocks;

 

 
require_once ('class.phpmailer.php');
    // read the database and get the emails..

	try{
	   $mail = new PHPMailer();

	$mail->IsSMTP();                                   // send via SMTP
	$mail->Host     = "localhost"; // SMTP servers
	$mail->SMTPAuth = true;     // turn on SMTP authentication
	}
	catch (Exception $e){
		echo($e.' - Error occured');
	}

http://php.net/manual/en/language.exceptions.php

 

-cb-

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.