[Cs-project-svn_notify] SF.net SVN: cs-project: [623] trunk/lib/globalFunctions.php
Brought to you by:
crazedsanity
From: <cra...@us...> - 2007-11-15 16:07:22
|
Revision: 623 http://cs-project.svn.sourceforge.net/cs-project/?rev=623&view=rev Author: crazedsanity Date: 2007-11-15 08:07:13 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Catch exceptions when sending emails. /lib/globalFunctions.php: * send_email(): -- put calls to send_single_email() into a try/catch block so exceptions will be caught (otherwise user would get the exception screen, and might re-submit until the email goes or they get bored... bad either way). * send_single_email(): -- logs errors or information about the message on success. Yay. -- NOTE: should probably add the email's subject line into the error message for max traceability... Modified Paths: -------------- trunk/lib/globalFunctions.php Modified: trunk/lib/globalFunctions.php =================================================================== --- trunk/lib/globalFunctions.php 2007-11-15 16:02:20 UTC (rev 622) +++ trunk/lib/globalFunctions.php 2007-11-15 16:07:13 UTC (rev 623) @@ -1492,11 +1492,21 @@ //if multiple recipients, must send multiple emails. if(is_array($toAddr)) { foreach($toAddr as $emailAddr) { - $retval = create_list($retval, send_single_email($emailAddr, $subject, $body)); + try { + $retval = create_list($retval, send_single_email($emailAddr, $subject, $body)); + } + catch(exception $e) { + $retval = create_list($retval, $emailAddr ." (failed: ". $e->getMessage() .")"); + } } } else { - $retval = send_single_email($toAddr, $subject, $body); + try { + $retval = send_single_email($toAddr, $subject, $body); + } + catch(exception $e) { + $retval = $toAddr ." (failed: ". $e->getMessage() .")"; + } } } else { @@ -1751,9 +1761,17 @@ $mail->Subject = $subject; $mail->Body = $bbCodeParser->parseString($body); $mail->WordWrap = 75; + + $logsObj = new logsClass($db, 'Email'); + if(!$mail->Send()) { - throw new exception(__FUNCTION__ .": Message could not be sent::: ". $mail->ErrorInfo); + $details = __FUNCTION__ .": Message to (". $toAddr .") could not be sent::: ". $mail->ErrorInfo; + $logsObj->log_by_class($details, 'error'); + throw new exception($details); } + else { + $logsObj->log_by_class('Successfully sent email to ('. $toAddr .'): '. $subject, 'information'); + } return($toAddr); }//end send_single_email() //============================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |