class CRM_Utils_Mail

Methods

static Mail
createMailer()

Create a new mailer to send any mail from the application.

static object
_createMailer(string $driver, array $params)

Create a new instance of a PEAR Mail driver.

static bool
send(array $params)

Wrapper function to send mail in CiviCRM. Hooks are called from this function. The input parameter is an associateive array which holds the values of field needed to send an email. These are:

static string
errorMessage($mailer, $result)

No description

static 
logger($to, $headers, $message)

No description

static string
pluckEmailFromHeader(string $header)

Get the email address itself from a formatted full name + address string

static bool
validOutBoundMail()

Get the Active outBound email.

static mixed
setMimeParams($message, array $params = NULL)

No description

static null|string
formatRFC822Email(string $name, $email, bool $useQuote = FALSE)

No description

static string
formatRFC2822Name(string $name)

Takes a string and checks to see if it needs to be escaped / double quoted and if so does the needful and return the formatted name

static array
appendPDF(string $fileName, string $html, string $format = NULL)

No description

static string
format(array $fields)

Format an email string from email fields.

static string
formatFromAddress(string $from)

When passed a value, returns the value if it's non-numeric.

Details

at line 45
static Mail createMailer()

Create a new mailer to send any mail from the application.

Note: The mailer is opened in persistent mode.

Note: You probably don't want to call this directly. Get a reference to the mailer through the container.

Return Value

Mail

at line 134
static object _createMailer(string $driver, array $params)

Create a new instance of a PEAR Mail driver.

Parameters

string $driver 'CRM_Mailing_BAO_Spool' or a name suitable for Mail::factory().
array $params

Return Value

object More specifically, a class which implements the "send()" function

at line 169
static bool send(array $params)

Wrapper function to send mail in CiviCRM. Hooks are called from this function. The input parameter is an associateive array which holds the values of field needed to send an email. These are:

from : complete from envelope toName : name of person to send email toEmail : email address to send to cc : email addresses to cc bcc : email addresses to bcc subject : subject of the email text : text of the message html : html version of the message replyTo : reply-to header in the email attachments: an associative array of fullPath : complete pathname to the file mime_type: mime type of the attachment cleanName: the user friendly name of the attachmment

Parameters

array $params (by reference).

Return Value

bool TRUE if a mail was sent, else FALSE.

at line 320
static string errorMessage($mailer, $result)

Parameters

$mailer
$result

Return Value

string

at line 344
static logger($to, $headers, $message)

Parameters

$to
$headers
$message

at line 384
static string pluckEmailFromHeader(string $header)

Get the email address itself from a formatted full name + address string

Ugly but working.

Parameters

string $header The full name + email address string.

Return Value

string the plucked email address

at line 399
static bool validOutBoundMail()

Get the Active outBound email.

Return Value

bool TRUE if valid outBound email configuration found, false otherwise.

at line 431
static mixed setMimeParams($message, array $params = NULL)

Parameters

$message
array $params

Return Value

mixed

at line 455
static null|string formatRFC822Email(string $name, $email, bool $useQuote = FALSE)

Parameters

string $name
$email
bool $useQuote

Return Value

null|string

at line 497
static string formatRFC2822Name(string $name)

Takes a string and checks to see if it needs to be escaped / double quoted and if so does the needful and return the formatted name

This code has been copied and adapted from ezc/Mail/src/tools.php

Parameters

string $name

Return Value

string

at line 521
static array appendPDF(string $fileName, string $html, string $format = NULL)

Parameters

string $fileName
string $html
string $format

Return Value

array

at line 550
static string format(array $fields)

Format an email string from email fields.

Parameters

array $fields The email fields.

Return Value

string The formatted email string.

at line 590
static string formatFromAddress(string $from)

When passed a value, returns the value if it's non-numeric.

If it's numeric, look up the display name and email of the corresponding contact ID in RFC822 format.

Parameters

string $from contact ID or formatted "From address", eg. 12 or "Fred Bloggs" fred@example.org

Return Value

string The RFC822-formatted email header (display name + address)