Page MenuHomePhabricator

mailpatch.diff

Authored By
bzimport
Nov 21 2014, 10:00 PM
Size
2 KB
Referenced Files
None
Subscribers
None

mailpatch.diff

Index: UserMailer.php
===================================================================
--- UserMailer.php (revision 30559)
+++ UserMailer.php (working copy)
@@ -72,22 +72,34 @@
}
}
-function send_mail($mailer, $dest, $headers, $body)
-{
- $mailResult =& $mailer->send($dest, $headers, $body);
+/**
+ * This function checks the result of the pear mailer in the fashion recommended by the Net-SMTP documentation and
+ * return a friendly error code
+ * Turned into a function because of multiple occurences
+ * @param return code from Mail::send
+ */
+function check_pear_mail_result($mailResult) {
# Based on the result return an error string,
- if ($mailResult === true) {
- return '';
- } elseif (is_object($mailResult)) {
- wfDebug( "PEAR::Mail failed: " . $mailResult->getMessage() . "\n" );
- return $mailResult->getMessage();
+ if ($mailResult == true) {
+ return '';
+ } else if (PEAR::isError($e)) {
+ wfDebug( "PEAR::Mail failed: " . $mailResult->getMessage() . "\n") ;
+ return $mailResult->getMessage();
} else {
- wfDebug( "PEAR::Mail failed, unknown error result\n" );
- return 'Mail object return unknown error.';
+ wfDebug( "PEAR::Mail failed, unknown error result\n" );
+ return 'Mail object return unknown error.';
}
}
+function send_mail($mailer, $dest, $headers, $body)
+{
+ wfDebug( "Starting send mail\n");
+
+ $mailResult = $mailer->send($dest, $headers, $body);
+ return check_pear_mail_result($mailResult);
+}
+
/**
* This function will perform a direct (authenticated) login to
* a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
@@ -151,9 +163,11 @@
if ($e != '')
return $e;
}
- } else
- return $mail_object->send($dest, $headers, $body);
-
+ } else {
+ $mailResult = $mail_object->send($dest, $headers, $body);
+ return check_pear_mail_result($mailResult);
+ }
+
} else {
# In the following $headers = expression we removed "Reply-To: {$from}\r\n" , because it is treated differently
# (fifth parameter of the PHP mail function, see some lines below)

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4133
Default Alt Text
mailpatch.diff (2 KB)

Event Timeline