Catch exceptions from PHPMailer

remotes/origin/stable45
Michael Gapczynski 13 years ago
parent 7077678f7f
commit 66da0a2151
  1. 54
      lib/mail.php

@ -56,33 +56,35 @@ class OC_Mail {
$mailo->From =$fromaddress;
$mailo->FromName = $fromname;;
$a=explode(' ',$toaddress);
foreach($a as $ad) {
$mailo->AddAddress($ad,$toname);
try {
foreach($a as $ad) {
$mailo->AddAddress($ad,$toname);
}
if($ccaddress<>'') $mailo->AddCC($ccaddress,$ccname);
if($bcc<>'') $mailo->AddBCC($bcc);
$mailo->AddReplyTo($fromaddress, $fromname);
$mailo->WordWrap = 50;
if($html==1) $mailo->IsHTML(true); else $mailo->IsHTML(false);
$mailo->Subject = $subject;
if($altbody=='') {
$mailo->Body = $mailtext.OC_MAIL::getfooter();
$mailo->AltBody = '';
}else{
$mailo->Body = $mailtext;
$mailo->AltBody = $altbody;
}
$mailo->CharSet = 'UTF-8';
$mailo->Send();
unset($mailo);
OC_Log::write('Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject,'mail',OC_Log::DEBUG);
} catch (Exception $exception) {
OC_Log::write('mail', $exception->getMessage(), OC_Log::DEBUG);
}
if($ccaddress<>'') $mailo->AddCC($ccaddress,$ccname);
if($bcc<>'') $mailo->AddBCC($bcc);
$mailo->AddReplyTo($fromaddress, $fromname);
$mailo->WordWrap = 50;
if($html==1) $mailo->IsHTML(true); else $mailo->IsHTML(false);
$mailo->Subject = $subject;
if($altbody=='') {
$mailo->Body = $mailtext.OC_MAIL::getfooter();
$mailo->AltBody = '';
}else{
$mailo->Body = $mailtext;
$mailo->AltBody = $altbody;
}
$mailo->CharSet = 'UTF-8';
$mailo->Send();
unset($mailo);
OC_Log::write('Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject,'mail',OC_Log::DEBUG);
}

Loading…
Cancel
Save