model/modx/mail/modmail.class.php
- package
- modx
- subpackage
- Classes
- modMail
Description
This file contains the modMail email service interface definition.
\modMail
- abstract
- Implement a derivative of this class to define an actual email service implementation.
- package
- modx
- subpackage
- Constants
- MAIL_BODY
- MAIL_BODY_TEXT
- MAIL_CHARSET
- MAIL_CONTENT_TYPE
- MAIL_ENCODING
- MAIL_ENGINE
- MAIL_ENGINE_PATH
- MAIL_ERROR_INFO
- MAIL_FROM
- MAIL_FROM_NAME
- MAIL_HOSTNAME
- MAIL_LANGUAGE
- MAIL_PRIORITY
- MAIL_READ_TO
- MAIL_SENDER
- MAIL_SERVICE
- MAIL_SMTP_AUTH
- MAIL_SMTP_HELO
- MAIL_SMTP_HOSTS
- MAIL_SMTP_KEEPALIVE
- MAIL_SMTP_PASS
- MAIL_SMTP_PORT
- MAIL_SMTP_PREFIX
- MAIL_SMTP_SINGLE_TO
- MAIL_SMTP_TIMEOUT
- MAIL_SMTP_USER
- MAIL_SUBJECT
- Properties
- $addresses
- $attributes
- $files
- $headers
- $mailer
- $modx
- Methods
- __construct
- _getMailer
- address
- attach
- clearAttachments
- get
- getDefaultAttributes
- header
- reset
- send
- set
Description
Defines the interface for the modX email service.
Constants
MAIL_BODY
MAIL_BODY = 'mail_body'
Details
- value
- mail_body
- const
- An option for setting the mail body
MAIL_BODY_TEXT
MAIL_BODY_TEXT = 'mail_body_text'
Details
- value
- mail_body_text
- const
- An option for setting the mail body text
MAIL_CHARSET
MAIL_CHARSET = 'mail_charset'
Details
- value
- mail_charset
- const
- An option for setting the mail charset
MAIL_CONTENT_TYPE
MAIL_CONTENT_TYPE = 'mail_content_type'
Details
- value
- mail_content_type
- const
- An option for setting the mail content type
MAIL_ENCODING
MAIL_ENCODING = 'mail_encoding'
Details
- value
- mail_encoding
- const
- An option for setting the mail encoding
MAIL_ENGINE
MAIL_ENGINE = 'mail_engine'
Details
- value
- mail_engine
- const
- An option for setting the mail engine
MAIL_ENGINE_PATH
MAIL_ENGINE_PATH = 'mail_engine_path'
Details
- value
- mail_engine_path
- const
- An option for setting the mail engine path
MAIL_ERROR_INFO
MAIL_ERROR_INFO = 'mail_error_info'
Details
- value
- mail_error_info
- const
- An option for setting the mail error information
MAIL_FROM
MAIL_FROM = 'mail_from'
Details
- value
- mail_from
- const
- An option for setting the mail From address
MAIL_FROM_NAME
MAIL_FROM_NAME = 'mail_from_name'
Details
- value
- mail_from_name
- const
- An option for setting the mail From name
MAIL_HOSTNAME
MAIL_HOSTNAME = 'mail_hostname'
Details
- value
- mail_hostname
- const
- An option for setting the mail hostname
MAIL_LANGUAGE
MAIL_LANGUAGE = 'mail_language'
Details
- value
- mail_language
- const
- An option for setting the mail language
MAIL_PRIORITY
MAIL_PRIORITY = 'mail_priority'
Details
- value
- mail_priority
- const
- An option for setting the mail priority header
MAIL_READ_TO
MAIL_READ_TO = 'mail_read_to'
Details
- value
- mail_read_to
- const
- An option for setting the mail read to header
MAIL_SENDER
MAIL_SENDER = 'mail_sender'
Details
- value
- mail_sender
- const
- An option for setting the mail sender
MAIL_SERVICE
MAIL_SERVICE = 'mail_service'
Details
- value
- mail_service
- const
- An option for setting the mail service
MAIL_SMTP_AUTH
MAIL_SMTP_AUTH = 'mail_smtp_auth'
Details
- value
- mail_smtp_auth
- const
- An option for setting the mail SMTP auth type
MAIL_SMTP_HELO
MAIL_SMTP_HELO = 'mail_smtp_helo'
Details
- value
- mail_smtp_helo
- const
- An option for setting the mail SMTP HELO boolean
MAIL_SMTP_HOSTS
MAIL_SMTP_HOSTS = 'mail_smtp_hosts'
Details
- value
- mail_smtp_hosts
- const
- An option for setting the mail SMTP hosts
MAIL_SMTP_KEEPALIVE
MAIL_SMTP_KEEPALIVE = 'mail_smtp_keepalive'
Details
- value
- mail_smtp_keepalive
- const
- An option for setting the mail SMTP Keep-Alive boolean
MAIL_SMTP_PASS
MAIL_SMTP_PASS = 'mail_smtp_pass'
Details
- value
- mail_smtp_pass
- const
- An option for setting the mail SMTP password
MAIL_SMTP_PORT
MAIL_SMTP_PORT = 'mail_smtp_port'
Details
- value
- mail_smtp_port
- const
- An option for setting the mail SMTP port
MAIL_SMTP_PREFIX
MAIL_SMTP_PREFIX = 'mail_smtp_prefix'
Details
- value
- mail_smtp_prefix
- const
- An option for setting the mail SMTP prefix
MAIL_SMTP_SINGLE_TO
MAIL_SMTP_SINGLE_TO = 'mail_smtp_single_to'
Details
- value
- mail_smtp_single_to
- const
- An option for setting the mail SMTP Single-To option
MAIL_SMTP_TIMEOUT
MAIL_SMTP_TIMEOUT = 'mail_smtp_timeout'
Details
- value
- mail_smtp_timeout
- const
- An option for setting the mail SMTP timeout
MAIL_SMTP_USER
MAIL_SMTP_USER = 'mail_smtp_user'
Details
- value
- mail_smtp_user
- const
- An option for setting the mail SMTP username
MAIL_SUBJECT
MAIL_SUBJECT = 'mail_subject'
Details
- value
- mail_subject
- const
- An option for setting the mail subject
Properties
$addresses
array $addresses = 'array'
An array of address types: to, cc, bcc, reply-to
Details
- array
- visibility
- public
- default
- array
- final
- false
- static
- false
$attributes
array $attributes = 'array'
A collection of attributes defining all of the details of email communication.
Details
- array
- visibility
- public
- default
- array
- final
- false
- static
- false
$files
array $files = 'array'
An array of attached files
Details
- array
- visibility
- public
- default
- array
- final
- false
- static
- false
$headers
array $headers = 'array'
A collection of all the current headers for the object.
Details
- array
- visibility
- public
- default
- array
- final
- false
- static
- false
$mailer
object $mailer = 'null'
The mailer object responsible for implementing the modMail methods.
Details
- object
- visibility
- public
- default
- null
- final
- false
- static
- false
$modx
Methods
__construct
__construct(
\modX $modx, array $attributes
=
array
)
:
Constructs a new instance of the modMail class.
Arguments
- $modx
- \modX
&$modx A reference to the modX instance - $attributes
- array
An array of attributes to assign to the new mail instance
Details
- visibility
- public
- final
- false
- static
- false
_getMailer
_getMailer(
)
:
boolean
Get an instance of the email class responsible for sending emails from the modEmail service.
{@internal Implement this function in derivatives and call it in the constructor after all other dependencies have been satisfied.}
Output
- boolean
- Indicates if the mailer class was instantiated successfully.
Details
- visibility
- protected
- final
- false
- static
- false
- abstract
- access
- protected
address
address(
string $type, string $email, string $name
)
:
boolean
Add a new recipient email address to one of the valid address type buckets.
Arguments
- $type
- string
The address type to add; to, cc, bcc, or reply-to. - string
The email address. - $name
- string
An optional name for the addressee.
Output
- boolean
- Indicates if the address was set/unset successfully.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
attach
attach(
string $file
)
:
Attach a file to the attachments queue.
Arguments
- $file
- string
The absolute path to the file
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
clearAttachments
clearAttachments(
)
:
Clear all existing attachments.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
get
get(
string $key
)
:
mixed
Gets a reference to an attribute of the mail object.
Arguments
- $key
- string
The attribute key.
Output
- mixed
- A reference to the attribute, or null if no attribute value is set for the key.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
getDefaultAttributes
getDefaultAttributes(
array $attributes
=
array
)
:
array
Gets the default attributes for modMail based on system settings
Arguments
- $attributes
- array
An optional array of default attributes to override with
Output
- array
- An array of default attributes
Details
- visibility
- public
- final
- false
- static
- false
header
header(
string $header
)
:
boolean
Adds a header to the mailer
Arguments
- $header
- string
The HTTP header to send.
Output
- boolean
- True if the header is valid and is set.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
reset
reset(
array $attributes
=
array
)
:
Reset the mail service, clearing addresses and attributes.
Arguments
- $attributes
- array
An optional array of attributes to apply after reset.
Details
- visibility
- public
- final
- false
- static
- false
- access
- public
send
send(
array $attributes
=
array
)
:
boolean
Send an email setting any supplied attributes before sending.
{@internal You should implement the rest of this method in a derivative class.}
Arguments
- $attributes
- array
Attributes to override any existing attributes before sending.
Output
- boolean
- Indicates if the email was sent successfully.
Details
- visibility
- public
- final
- false
- static
- false
- abstract
- access
- public
set
set(
string $key, mixed $value
)
:
Sets the value of an attribute of the mail object.
{@internal Override this method in a derivative to set the appropriate attributes of the actual mailer implementation being used. Make sure to call this parent implementation first and then set the value of the corresponding mailer attribute as a reference to the attribute set in $this->attributes}
Arguments
- $key
- string
The key of the attribute to set. - $value
- mixed
The value of the attribute.
Details
- visibility
- public
- final
- false
- static
- false
- abstract
- access
- public