Documentation

CRM_Utils_Mail
in package

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Methods

_createMailer()  : object
Create a new instance of a PEAR Mail driver.
appendPDF()  : array<string|int, mixed>
createMailer()  : Mail
Create a new mailer to send any mail from the application.
errorMessage()  : string
format()  : string
Format an email string from email fields.
formatFromAddress()  : string
When passed a value, returns the value if it's non-numeric.
formatRFC2822Name()  : string
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
formatRFC822Email()  : null|string
pluckEmailFromHeader()  : string
Get the email address itself from a formatted full name + address string
send()  : bool
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. Note that these parameters are case-sensitive. The Parameters are:
sendTest()  : bool
Send a test email using the selected mailer.
setEmailHeaders()  : array<string|int, mixed>
Set email headers
setMimeParams()  : mixed
validOutBoundMail()  : bool
Get the Active outBound email.

Methods

_createMailer()

Create a new instance of a PEAR Mail driver.

public static _createMailer(string $driver, array<string|int, mixed> $params) : object
Parameters
$driver : string

'CRM_Mailing_BAO_Spool' or a name suitable for Mail::factory().

$params : array<string|int, mixed>
Return values
object

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

appendPDF()

public static appendPDF(string $fileName, string $html[, string $format = NULL ]) : array<string|int, mixed>
Parameters
$fileName : string
$html : string
$format : string = NULL
Return values
array<string|int, mixed>

createMailer()

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

public static createMailer() : Mail

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.

Tags
throws
CRM_Core_Exception
Return values
Mail

errorMessage()

public static errorMessage(mixed $mailer, mixed $result) : string
Parameters
$mailer : mixed
$result : mixed
Return values
string

format()

Format an email string from email fields.

public static format(array<string|int, mixed> $fields) : string
Parameters
$fields : array<string|int, mixed>

The email fields.

Return values
string

The formatted email string.

formatFromAddress()

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

public static formatFromAddress(string $from) : string

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

Parameters
$from : string

civicrm_email.id or formatted "From address", eg. 12 or "Fred Bloggs" fred@example.org

Return values
string

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

formatRFC2822Name()

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

public static formatRFC2822Name(string $name) : string

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

Parameters
$name : string
Return values
string

formatRFC822Email()

public static formatRFC822Email(string $name, string $email[, bool $useQuote = FALSE ]) : null|string
Parameters
$name : string
$email : string
$useQuote : bool = FALSE
Return values
null|string

pluckEmailFromHeader()

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

public static pluckEmailFromHeader(string $header) : string

Ugly but working.

Parameters
$header : string

The full name + email address string.

Return values
string

the plucked email address

send()

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. Note that these parameters are case-sensitive. The Parameters are:

public static send(array<string|int, mixed> &$params) : bool

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 returnpath : email address for bounces to be sent to messageId : Message ID for this email mesage 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 contactId : contact id to send the email to (optional)

Parameters
$params : array<string|int, mixed>

(by reference).

Return values
bool

TRUE if a mail was sent, else FALSE.

sendTest()

Send a test email using the selected mailer.

public static sendTest(Mail $mailer, array<string|int, mixed> &$params) : bool
Parameters
$mailer : Mail
$params : array<string|int, mixed>

Params by reference.

Return values
bool

TRUE if a mail was sent, else FALSE.

setEmailHeaders()

Set email headers

public static setEmailHeaders(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of the Headers and Message.

setMimeParams()

public static setMimeParams(mixed $message[, array<string|int, mixed> $params = NULL ]) : mixed
Parameters
$message : mixed
$params : array<string|int, mixed> = NULL

validOutBoundMail()

Get the Active outBound email.

public static validOutBoundMail() : bool
Return values
bool

TRUE if valid outBound email configuration found, false otherwise.


        
On this page

Search results