summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-07-11 15:36:27 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-07-11 19:38:57 -0400
commite887fd7ba8c0fb4414489cfaf185987d5ac6347a (patch)
treedc00c8c43a0212d087a4a31fd1d5d95c8ba2875d
parentebcf5bce3c04870730d215f3ffde12cdcf1cc428 (diff)
downloadnextcloud-server-e887fd7ba8c0fb4414489cfaf185987d5ac6347a.tar.gz
nextcloud-server-e887fd7ba8c0fb4414489cfaf185987d5ac6347a.zip
Catch exceptions from PHPMailer
-rw-r--r--lib/mail.php54
1 files changed, 28 insertions, 26 deletions
diff --git a/lib/mail.php b/lib/mail.php
index b46f73bd94b..e218531afb2 100644
--- a/lib/mail.php
+++ b/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);
-
}