MediaWiki  1.23.2
UserMailer Class Reference

Collection of static functions for sending mail. More...

Static Public Member Functions

static arrayToHeaderString ( $headers, $endl="\n")
 Creates a single string from an associative array. More...
 
static errorHandler ( $code, $string)
 Set the mail error message in self::$mErrorString. More...
 
static makeMsgId ()
 Create a value suitable for the MessageId Header. More...
 
static quotedPrintable ( $string, $charset='')
 Converts a string into quoted-printable format. More...
 
static rfc822Phrase ( $phrase)
 Converts a string into a valid RFC 822 "phrase", such as is used for the sender name. More...
 
static sanitizeHeaderValue ( $val)
 Strips bad characters from a header value to prevent PHP mail header injection attacks. More...
 
static send ( $to, $from, $subject, $body, $replyto=null, $contentType='text/plain;charset=UTF-8')
 This function will perform a direct (authenticated) login to a SMTP Server to use for mail relaying if 'wgSMTP' specifies an array of parameters. More...
 

Static Public Attributes

static $mErrorString
 

Static Protected Member Functions

static quotedPrintableCallback ( $matches)
 
static sendWithPear ( $mailer, $dest, $headers, $body)
 Send mail using a PEAR mailer. More...
 

Detailed Description

Collection of static functions for sending mail.

Definition at line 83 of file UserMailer.php.

Member Function Documentation

◆ arrayToHeaderString()

static UserMailer::arrayToHeaderString (   $headers,
  $endl = "\n" 
)
static

Creates a single string from an associative array.

Parameters
array$headersAssociative Array: keys are header field names, values are ... values.
string$endlThe end of line character. Defaults to "\n"

Note RFC2822 says newlines must be CRLF (\r
) but php mail naively "corrects" it and requires
for the "correction" to work

Returns
String

Definition at line 120 of file UserMailer.php.

References $name, $value, array(), as, and sanitizeHeaderValue().

Referenced by send().

◆ errorHandler()

static UserMailer::errorHandler (   $code,
  $string 
)
static

Set the mail error message in self::$mErrorString.

Parameters
$codeInteger: error number
string$stringerror message

Definition at line 393 of file UserMailer.php.

◆ makeMsgId()

static UserMailer::makeMsgId ( )
static

Create a value suitable for the MessageId Header.

Returns
String

Definition at line 135 of file UserMailer.php.

References global, wfParseUrl(), and wfWikiID().

Referenced by send().

◆ quotedPrintable()

static UserMailer::quotedPrintable (   $string,
  $charset = '' 
)
static

Converts a string into quoted-printable format.

Since
1.17

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

Returns
string

Definition at line 430 of file UserMailer.php.

References $out, and array().

Referenced by send(), UserMailerTest\testQuotedPrintable(), and MailAddress\toString().

◆ quotedPrintableCallback()

static UserMailer::quotedPrintableCallback (   $matches)
staticprotected

Definition at line 450 of file UserMailer.php.

References $matches.

◆ rfc822Phrase()

static UserMailer::rfc822Phrase (   $phrase)
static

Converts a string into a valid RFC 822 "phrase", such as is used for the sender name.

Parameters
$phrasestring
Returns
string

Definition at line 411 of file UserMailer.php.

References sanitizeHeaderValue().

◆ sanitizeHeaderValue()

static UserMailer::sanitizeHeaderValue (   $val)
static

Strips bad characters from a header value to prevent PHP mail header injection attacks.

Parameters
string$valString to be santizied
Returns
string

Definition at line 402 of file UserMailer.php.

References array().

Referenced by arrayToHeaderString(), and rfc822Phrase().

◆ send()

static UserMailer::send (   $to,
  $from,
  $subject,
  $body,
  $replyto = null,
  $contentType = 'text/plain; charset=UTF-8' 
)
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.

Parameters
$toMailAddress: recipient's email (or an array of them)
$fromMailAddress: sender's email
string$subjectemail's subject.
string$bodyemail's text or Array of two strings to be the text and html bodies
$replytoMailAddress: optional reply-to email (default: null).
string$contentTypeoptional custom Content-Type (default: text/plain; charset=UTF-8)
Exceptions
MWException
Returns
Status object

Definition at line 163 of file UserMailer.php.

References $e, $from, $mime, $ret, array(), arrayToHeaderString(), as, MWTimestamp\getLocalInstance(), global, mail, makeMsgId(), Status\newFatal(), Status\newGood(), quotedPrintable(), sendWithPear(), wfDebug(), wfIniGetBool(), wfIsWindows(), wfRestoreWarnings(), wfRunHooks(), and wfSuppressWarnings().

Referenced by EmaillingJob\run(), EmailNotification\sendImpersonal(), User\sendMail(), EmailNotification\sendPersonalised(), and SpecialEmailUser\submit().

◆ sendWithPear()

static UserMailer::sendWithPear (   $mailer,
  $dest,
  $headers,
  $body 
)
staticprotected

Send mail using a PEAR mailer.

Parameters
$mailer
$dest
$headers
$body
Returns
Status

Definition at line 96 of file UserMailer.php.

References Status\newFatal(), Status\newGood(), and wfDebug().

Referenced by send().

Member Data Documentation

◆ $mErrorString

UserMailer::$mErrorString
static

Definition at line 84 of file UserMailer.php.


The documentation for this class was generated from the following file: