VuFind API Documentation

Mailer
in package
implements TranslatorAwareInterface, LoggerAwareInterface Uses TranslatorAwareTrait, LoggerAwareTrait

VuFind Mailer Class

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Interfaces, Classes, Traits and Enums

TranslatorAwareInterface
Lightweight translator aware marker interface (used as an alternative to \Laminas\I18n\Translator\TranslatorAwareInterface, which requires an excessive number of methods to be implemented).
LoggerAwareInterface

Table of Contents

$fromAddressOverride  : string
"From" address override
$initialTransport  : TransportInterface
A clone of $transport above. This can be used to reset the connection state in case transport doesn't support the disconnect method or it throws an exception (this can happen if the connection is stale and the connector tries to issue a QUIT message for clean disconnect).
$maxRecipients  : int
The maximum number of email recipients allowed (0 = no limit)
$messageLog  : string|null
$translator  : TranslatorInterface
Translator
$transport  : TransportInterface
Mail transport
__construct()  : mixed
Constructor
buildMultipartBody()  : Message
Constructs a {@see MimeMessage} body from given text and html content.
getDefaultLinkSubject()  : string
Get the default subject line for sendLink().
getDefaultRecordSubject()  : string
Get the default subject line for sendRecord()
getFromAddressOverride()  : string
Get the "From" address override value
getNewBlankMessage()  : Message
Get a blank email message object.
getNewMessage()  : Message
Get a text email message object.
getTranslator()  : TranslatorInterface
Get translator object.
getTranslatorLocale()  : string
Get the locale from the translator.
getTransport()  : TransportInterface
Get the mail transport object.
resetConnection()  : Mailer
Reset the connection in the transport. Implements a fluent interface.
send()  : void
Send an email message.
sendLink()  : void
Send an email message representing a link.
sendRecord()  : void
Send an email message representing a record.
setFromAddressOverride()  : void
Set the "From" address override
setMaxRecipients()  : void
Set the maximum number of email recipients
setTranslator()  : TranslatorAwareInterface
Set a translator
setTransport()  : void
Set the mail transport object.
stringToAddressList()  : AddressList
Convert a delimited string to an address list.
translate()  : string
Translate a string (or string-castable object)
translateWithPrefix()  : string
Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.
convertToAddressList()  : AddressList
Convert the given addresses to an AddressList object
debug()  : void
Log a debug message.
extractTextDomain()  : array<string|int, mixed>
Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.
getDebugTranslation()  : string
Build a debug-mode translation
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
sanitizeTranslationKey()  : string
Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.
translateString()  : string
Get translation for a string

Properties

$fromAddressOverride

"From" address override

protected string $fromAddressOverride = ''

$initialTransport

A clone of $transport above. This can be used to reset the connection state in case transport doesn't support the disconnect method or it throws an exception (this can happen if the connection is stale and the connector tries to issue a QUIT message for clean disconnect).

protected TransportInterface $initialTransport

$maxRecipients

The maximum number of email recipients allowed (0 = no limit)

protected int $maxRecipients = 1

$messageLog

protected string|null $messageLog = null

$transport

Mail transport

protected TransportInterface $transport

Methods

__construct()

Constructor

public __construct(TransportInterface $transport[, string|null $messageLog = null ]) : mixed
Parameters
$transport : TransportInterface

Mail transport

$messageLog : string|null = null

File to log messages into (null for no logging)

Return values
mixed

buildMultipartBody()

Constructs a {@see MimeMessage} body from given text and html content.

public buildMultipartBody([string|null $text = null ][, string|null $html = null ]) : Message
Parameters
$text : string|null = null

Mail content used for plain text part

$html : string|null = null

Mail content used for html part

Return values
Message

getDefaultLinkSubject()

Get the default subject line for sendLink().

public getDefaultLinkSubject() : string
Return values
string

getDefaultRecordSubject()

Get the default subject line for sendRecord()

public getDefaultRecordSubject(AbstractBase $record) : string
Parameters
$record : AbstractBase

Record being emailed

Return values
string

getFromAddressOverride()

Get the "From" address override value

public getFromAddressOverride() : string
Return values
string

getNewBlankMessage()

Get a blank email message object.

public getNewBlankMessage() : Message
Return values
Message

getNewMessage()

Get a text email message object.

public getNewMessage() : Message
Return values
Message

getTranslator()

Get translator object.

public getTranslator() : TranslatorInterface
Return values
TranslatorInterface

getTranslatorLocale()

Get the locale from the translator.

public getTranslatorLocale([string $default = 'en' ]) : string
Parameters
$default : string = 'en'

Default to use if translator absent.

Return values
string

getTransport()

Get the mail transport object.

public getTransport() : TransportInterface
Return values
TransportInterface

resetConnection()

Reset the connection in the transport. Implements a fluent interface.

public resetConnection() : Mailer
Return values
Mailer

send()

Send an email message.

public send(string|Address|AddressList $to, string|Address $from, string $subject, string|Message $body[, string $cc = null ][, string|Address|AddressList $replyTo = null ]) : void
Parameters
$to : string|Address|AddressList

Recipient email address (or delimited list)

$from : string|Address

Sender name and email address

$subject : string

Subject line for message

$body : string|Message

Message body

$cc : string = null

CC recipient (null for none)

$replyTo : string|Address|AddressList = null

Reply-To address (or delimited list, null for none)

Tags
throws
Mail
Return values
void

Send an email message representing a link.

public sendLink(string $to, string|Address $from, string $msg, string $url, PhpRenderer $view[, string $subject = null ][, string $cc = null ][, string|Address|AddressList $replyTo = null ]) : void
Parameters
$to : string

Recipient email address

$from : string|Address

Sender name and email address

$msg : string

User notes to include in message

$url : string

URL to share

$view : PhpRenderer

View object (used to render email templates)

$subject : string = null

Subject for email (optional)

$cc : string = null

CC recipient (null for none)

$replyTo : string|Address|AddressList = null

Reply-To address (or delimited list, null for none)

Tags
throws
Mail
Return values
void

sendRecord()

Send an email message representing a record.

public sendRecord(string $to, string|Address $from, string $msg, AbstractBase $record, PhpRenderer $view[, string $subject = null ][, string $cc = null ][, string|Address|AddressList $replyTo = null ]) : void
Parameters
$to : string

Recipient email address

$from : string|Address

Sender name and email address

$msg : string

User notes to include in message

$record : AbstractBase

Record being emailed

$view : PhpRenderer

View object (used to render email templates)

$subject : string = null

Subject for email (optional)

$cc : string = null

CC recipient (null for none)

$replyTo : string|Address|AddressList = null

Reply-To address (or delimited list, null for none)

Tags
throws
Mail
Return values
void

setFromAddressOverride()

Set the "From" address override

public setFromAddressOverride(string $address) : void
Parameters
$address : string

"From" address

Return values
void

setMaxRecipients()

Set the maximum number of email recipients

public setMaxRecipients(int $max) : void
Parameters
$max : int

Maximum

Return values
void

setTransport()

Set the mail transport object.

public setTransport(TransportInterface $transport) : void
Parameters
$transport : TransportInterface

Mail transport object

Return values
void

stringToAddressList()

Convert a delimited string to an address list.

public stringToAddressList(string $input) : AddressList
Parameters
$input : string

String to convert

Return values
AddressList

translate()

Translate a string (or string-castable object)

public translate(string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

translateWithPrefix()

Translate a string (or string-castable object) using a prefix, or without the prefix if a prefixed translation is not found.

public translateWithPrefix(string $prefix, string|object|array<string|int, mixed> $target[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, bool $useIcuFormatter = false ][, array<string|int, string> $fallbackDomains = [] ]) : string
Parameters
$prefix : string

Translation key prefix

$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

$fallbackDomains : array<string|int, string> = []

Text domains to check if no match is found in the domain specified in $target

Return values
string

convertToAddressList()

Convert the given addresses to an AddressList object

protected convertToAddressList(string|Address|AddressList $addresses) : AddressList
Parameters
$addresses : string|Address|AddressList

Addresses

Return values
AddressList

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

extractTextDomain()

Given a translation string with or without a text domain, return an array with the raw string and the text domain separated.

protected extractTextDomain(string|object|array<string|int, mixed> $target) : array<string|int, mixed>
Parameters
$target : string|object|array<string|int, mixed>

String to translate or an array of text domain and string to translate

Return values
array<string|int, mixed>

getDebugTranslation()

Build a debug-mode translation

protected getDebugTranslation(string $domain, string $str, array<string|int, mixed> $tokens) : string
Parameters
$domain : string

Text domain

$str : string

String to translate

$tokens : array<string|int, mixed>

Tokens to inject into the translated string

Return values
string

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

sanitizeTranslationKey()

Make sure there are not any illegal characters in the translation key that might prevent successful lookup in language files.

protected sanitizeTranslationKey(string $key) : string
Parameters
$key : string

Key to sanitize

Return values
string

Sanitized key

translateString()

Get translation for a string

protected translateString(string $rawStr[, array<string|int, mixed> $tokens = [] ][, string $default = null ][, string $domain = 'default' ][, bool $useIcuFormatter = false ]) : string
Parameters
$rawStr : string

String to translate

$tokens : array<string|int, mixed> = []

Tokens to inject into the translated string

$default : string = null

Default value to use if no translation is found (null for no default).

$domain : string = 'default'

Text domain (omit for default)

$useIcuFormatter : bool = false

Should we use an ICU message formatter instead of the default behavior?

Return values
string

Search results