Blesta Source Documentation

Email extends Component uses Container

A wrapper component for Symfony Mailer.

https://symfony.com/doc/current/mailer.html#other-options

Table of Contents

Properties

$Logs
$tag_end
$tag_start
$components
$helpers
$models
$charset
$email
$mailer
$options
$tags
$threshold

Methods

__construct() Constructs a new Email component
addAddress() Invokes parent::AddAddress()
addAttachment() Adds the attachment
addBcc() Invokes parent::AddBCC()
addCc() Invokes parent::AddCC()
addReplyTo() Invokes parent::setReplyTo()
buildTransport() Builds and initializes a transport class
getTransport() Gets the transport object to be used for all subsequent requests
resetAll() Resets all recipients, replytos, attachments, and custom headers, body and subject, and replacement tags (if any).
send() Invokes parent::Send() and logs the result
setAltBody() Sets the alternate body of the message, replacing the given tags with their key/value pairs.
setBody() Sets the body of the message, replacing the given tags with their key/value pairs.
setFloodResistance() Set the flood resistance for sending messages
setFrom() Invokes parent::SetFrom()
setLogBody() Sets an alternate body for logging purposes, replacing the given tags with their key/value pairs.
setLogOptions() Sets the log options to be recorded when the message is attempted
setSubject() Sets the subject of the message, replacing the given tags with their key/value pairs.
setTags() Sets the given array of tags for replacement.
setTransport() Sets the transport object to be used for all subsequent requests
getFromContainer() Fetch an item from the container
log() Log the last sent message to the Logs
getAddresses() Returns a string of address from an array of Address objects
replaceTags() Replaces tags in the given $str with the supplied key/value replacements, if a tag exists in Email::$tags, but is not found in $replacements, it will be replaced with null.
Properties

$Logs

public Logs $Logs

The logs Model, used to record outgoing messages

$tag_end

public string $tag_end = ']'

The right tag enclosure

$tag_start

public string $tag_start = '['

The left tag enclosure

$charset

private string $charset

The default character set encoding.

$email

private SymfonyEmail $email

The email object for this instance

$mailer

private SymfonyMailer $mailer

The mailer used to send the message

$options

private array<string|int, mixed> $options = []

An array of options to log when this message is attempted to be sent

$tags

private array<string|int, mixed> $tags = []

All tags set for replacement

$threshold

private array<string|int, mixed> $threshold = []

An array of options containing the maximum number of messages to send before re-starting the transport

Methods

__construct()

Constructs a new Email component

public __construct([string $charset = 'utf-8' ]) : mixed
Parameters
$charset : string = 'utf-8'

The default character set encoding.

addAddress()

Invokes parent::AddAddress()

public addAddress(string $address[, string $name = '' ]) : mixed
Parameters
$address : string

The email address to add as a TO address

$name : string = ''

The TO name

addAttachment()

Adds the attachment

public addAttachment(string $path[, string $name = null ][, string $encoding = null ][, string $type = null ]) : mixed
Parameters
$path : string

The path to the file

$name : string = null

The name of the file

$encoding : string = null

The encoding of the file (deprecated, for backwards compatibility only)

$type : string = null

The MIME type of the file (optional)

addBcc()

Invokes parent::AddBCC()

public addBcc(string $address[, string $name = '' ]) : mixed
Parameters
$address : string

The email address to add as a BCC address

$name : string = ''

The BCC name

addCc()

Invokes parent::AddCC()

public addCc(string $address[, string $name = '' ]) : mixed
Parameters
$address : string

The email address to add as a CC address

$name : string = ''

The CC name

addReplyTo()

Invokes parent::setReplyTo()

public addReplyTo(string $address[, string $name = '' ]) : mixed
Parameters
$address : string

The email address to add as a ReplyTo address

$name : string = ''

The ReplyTo name

buildTransport()

Builds and initializes a transport class

public buildTransport(string $transport[, array<string|int, mixed> $vars = [] ]) : TransportInterface
Parameters
$transport : string

The name of the transport to build

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

The parameters to pass to the transport

Return values
TransportInterface

The transport object use to send the message

getTransport()

Gets the transport object to be used for all subsequent requests

public getTransport(TransportInterface $transport) : TransportInterface
Parameters
$transport : TransportInterface
Return values
TransportInterface

The transport object used to send the message (SMTP, Sendmail, etc.)

resetAll()

Resets all recipients, replytos, attachments, and custom headers, body and subject, and replacement tags (if any).

public resetAll() : mixed

send()

Invokes parent::Send() and logs the result

public send([mixed $throw_exceptions = false ]) : mixed
Parameters
$throw_exceptions : mixed = false

setAltBody()

Sets the alternate body of the message, replacing the given tags with their key/value pairs.

public setAltBody(string $body[, array<string|int, mixed> $replacements = [] ]) : mixed
Parameters
$body : string

The body of the message

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

The key/value pairs of tag replacements

Tags
see
Email::setTags()

setBody()

Sets the body of the message, replacing the given tags with their key/value pairs.

public setBody(string $body[, bool $is_html = false ][, array<string|int, mixed> $replacements = [] ]) : mixed
Parameters
$body : string

The body of the message

$is_html : bool = false

True if $body is HTML, false otherwise

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

The key/value pairs of tag replacements

Tags
see
Email::setTags()

setFloodResistance()

Set the flood resistance for sending messages

public setFloodResistance(int $threshold[, int $sleep = 0 ]) : mixed
Parameters
$threshold : int

The maximum number of messages to send before disconnecting/reconnecting to the mail server

$sleep : int = 0

The number of seconds to pause before reconnecting

setFrom()

Invokes parent::SetFrom()

public setFrom(string $from[, string $from_name = '' ]) : mixed
Parameters
$from : string

The from address

$from_name : string = ''

The from name for this from address

setLogBody()

Sets an alternate body for logging purposes, replacing the given tags with their key/value pairs.

public setLogBody(stdClass $body[, array<string|int, mixed> $replacements = [] ]) : mixed
Parameters
$body : stdClass

The masked email containing the body of the message

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

The key/value pairs of tag replacements

Tags
see
Email::setTags()

setLogOptions()

Sets the log options to be recorded when the message is attempted

public setLogOptions(array<string|int, mixed> $options) : mixed
Parameters
$options : array<string|int, mixed>

An array of options to log when this message is attempted to be sent including:

  • company_id The ID of the company the message is being sent by
  • to_client_id The ID of the client the message is being sent to (optional)
  • from_staff_id The ID of the staff member the message is sent by (optional)
  • log Bool true or false, whether to log the email (optional, default true)

setSubject()

Sets the subject of the message, replacing the given tags with their key/value pairs.

public setSubject(string $subject[, array<string|int, mixed> $replacements = [] ]) : mixed
Parameters
$subject : string

The subject of the message

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

The key/value pairs of tag replacements

Tags
see
Email::setTags()

setTags()

Sets the given array of tags for replacement.

public setTags(array<string|int, mixed> $tags) : mixed
Parameters
$tags : array<string|int, mixed>

The tags to set for replacement.

Tags
see
Email::replaceTags()

setTransport()

Sets the transport object to be used for all subsequent requests

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

getFromContainer()

Fetch an item from the container

protected getFromContainer(string $service) : mixed
Parameters
$service : string

The name of the service from the container to fetch

Return values
mixed

The service if found, otherwise null

log()

Log the last sent message to the Logs

protected log(array<string|int, mixed> $vars) : mixed
Parameters
$vars : array<string|int, mixed>

A key/value array of data to log, including:

  • log If false, will not log the email
    • Any other fields to log

getAddresses()

Returns a string of address from an array of Address objects

private getAddresses(array<string|int, mixed> $addresses[, bool $names_only = false ]) : string
Parameters
$addresses : array<string|int, mixed>

An array of Address objects

$names_only : bool = false

True to return the name of the addresses

Return values
string

A string of addresses

replaceTags()

Replaces tags in the given $str with the supplied key/value replacements, if a tag exists in Email::$tags, but is not found in $replacements, it will be replaced with null.

private replaceTags(string $str, array<string|int, mixed> $replacements) : string
Parameters
$str : string

The string to run replacements on.

$replacements : array<string|int, mixed>

The key/value replacements.

Return values
string

The string with all replacements done.

Tags
subpackage

components.email

copyright

Copyright (c) 2022, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results