MediaWiki REL1_31
|
Collection of static functions for sending mail. More...
Static Public Member Functions | |
static | arrayToHeaderString ( $headers, $endl=PHP_EOL) |
Creates a single string from an associative array. | |
static | errorHandler ( $code, $string) |
Set the mail error message in self::$mErrorString. | |
static | makeMsgId () |
Create a value suitable for the MessageId Header. | |
static | quotedPrintable ( $string, $charset='') |
Converts a string into quoted-printable format. | |
static | rfc822Phrase ( $phrase) |
Converts a string into a valid RFC 822 "phrase", such as is used for the sender name. | |
static | sanitizeHeaderValue ( $val) |
Strips bad characters from a header value to prevent PHP mail header injection attacks. | |
static | send ( $to, $from, $subject, $body, $options=[]) |
This function will perform a direct (authenticated) login to a SMTP Server to use for mail relaying if 'wgSMTP' specifies an array of parameters. | |
Static Protected Member Functions | |
static | sendInternal (array $to, MailAddress $from, $subject, $body, $options=[]) |
Helper function fo UserMailer::send() which does the actual sending. | |
static | sendWithPear ( $mailer, $dest, $headers, $body) |
Send mail using a PEAR mailer. | |
Static Private Member Functions | |
static | isMailMimeUsable () |
Whether the PEAR Mail_mime library is usable. | |
static | isMailUsable () |
Whether the PEAR Mail library is usable. | |
Static Private Attributes | |
static | $mErrorString |
Collection of static functions for sending mail.
Definition at line 30 of file UserMailer.php.
|
static |
Creates a single string from an associative array.
array | $headers | Associative Array: keys are header field names, values are ... values. |
string | $endl | The end of line character. Defaults to "\\n" |
Note RFC2822 says newlines must be CRLF (\r\n) but php mail naively "corrects" it and requires \n for the "correction" to work
Definition at line 67 of file UserMailer.php.
References $value, and sanitizeHeaderValue().
Referenced by sendInternal().
|
static |
Set the mail error message in self::$mErrorString.
int | $code | Error number |
string | $string | Error message |
Definition at line 468 of file UserMailer.php.
|
staticprivate |
Whether the PEAR Mail_mime library is usable.
This will try and load it if it is not already.
Definition at line 198 of file UserMailer.php.
|
staticprivate |
Whether the PEAR Mail library is usable.
This will try and load it if it is not already.
Definition at line 212 of file UserMailer.php.
|
static |
Create a value suitable for the MessageId Header.
Definition at line 82 of file UserMailer.php.
References $wgServer, $wgSMTP, wfParseUrl(), and wfWikiID().
Referenced by sendInternal().
|
static |
Converts a string into quoted-printable format.
From PHP5.3 there is a built in function quoted_printable_encode() This method does not duplicate that. This method is doing Q encoding inside encoded-words as defined by RFC 2047 This is for email headers. The built in quoted_printable_encode() is for email bodies
string | $string | |
string | $charset |
Definition at line 507 of file UserMailer.php.
References $matches, and $out.
Referenced by sendInternal(), UserMailerTest\testQuotedPrintable(), and MailAddress\toString().
|
static |
Converts a string into a valid RFC 822 "phrase", such as is used for the sender name.
string | $phrase |
Definition at line 486 of file UserMailer.php.
References sanitizeHeaderValue().
|
static |
Strips bad characters from a header value to prevent PHP mail header injection attacks.
string | $val | String to be santizied |
Definition at line 477 of file UserMailer.php.
Referenced by arrayToHeaderString(), and rfc822Phrase().
|
static |
This function will perform a direct (authenticated) login to a SMTP Server to use for mail relaying if 'wgSMTP' specifies an array of parameters.
It requires PEAR:Mail to do that. Otherwise it just uses the standard PHP 'mail' function.
MailAddress | MailAddress[] | $to | Recipient's email (or an array of them) |
MailAddress | $from | Sender's email |
string | $subject | Email's subject. |
string | $body | Email's text or Array of two strings to be the text and html bodies |
array | $options | Keys: 'replyTo' MailAddress 'contentType' string default 'text/plain; charset=UTF-8' 'headers' array Extra headers to set |
MWException | |
Exception |
Definition at line 114 of file UserMailer.php.
References $options, $wgAllowHTMLEmail, sendInternal(), and wfDebug().
Referenced by EmaillingJob\run(), EmailNotification\sendImpersonal(), User\sendMail(), EmailNotification\sendPersonalised(), and SpecialEmailUser\submit().
|
staticprotected |
Helper function fo UserMailer::send() which does the actual sending.
It expects a $to list which the UserMailerSplitTo hook would not split further.
MailAddress[] | $to | Array of recipients' email addresses |
MailAddress | $from | Sender's email |
string | $subject | Email's subject. |
string | $body | Email's text or Array of two strings to be the text and html bodies |
array | $options | Keys: 'replyTo' MailAddress 'contentType' string default 'text/plain; charset=UTF-8' 'headers' array Extra headers to set |
MWException | |
Exception |
Definition at line 237 of file UserMailer.php.
References $e, $mime, $options, $ret, $wgAdditionalMailParams, $wgEnotifMaxRecips, $wgSMTP, arrayToHeaderString(), Mail\factory(), PEAR\isError(), mail, makeMsgId(), PROTO_CANONICAL, quotedPrintable(), sendWithPear(), MailAddress\toString(), wfDebug(), and wfIsWindows().
Referenced by send().
|
staticprotected |
Send mail using a PEAR mailer.
Mail_smtp | $mailer | |
string | $dest | |
string | $headers | |
string | $body |
Definition at line 43 of file UserMailer.php.
References PEAR\isError(), and wfDebug().
Referenced by sendInternal().
|
staticprivate |
Definition at line 31 of file UserMailer.php.