Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4568
mailpatch.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 10:00 PM
2014-11-21 22:00:47 (UTC+0)
Size
2 KB
Referenced Files
None
Subscribers
None
mailpatch.diff
View Options
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
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4133
Default Alt Text
mailpatch.diff (2 KB)
Attached To
Mode
T13567: bogus email error message when creating an account ($wgSMTP only)
Attached
Detach File
Event Timeline
Log In to Comment