core/model/modx/mail/modmail.class.php
This file contains the modMail email service interface definition.
- Package
- modx
- Subpackage
\modMail
Defines the interface for the modX email service.
- Children
- \modPHPMailer
- Abstract
- Implement a derivative of this class to define an actual email service implementation.
Constants
MAIL_SMTP_KEEPALIVE
= 'mail_smtp_keepalive'- Const
- An option for setting the mail SMTP Keep-Alive boolean
MAIL_SMTP_SINGLE_TO
= 'mail_smtp_single_to'- Const
- An option for setting the mail SMTP Single-To option
Properties

array
$addresses= 'array(
'to' => array(),
'cc' => array(),
'bcc' => array(),
'reply-to' => array(),
)'
An array of address types: to, cc, bcc, reply-to
array(
'to' => array(),
'cc' => array(),
'bcc' => array(),
'reply-to' => array(),
)Details- Type
- array

array
$attributes= 'array()'
A collection of attributes defining all of the details of email communication.
array()Details- Type
- array

array
$headers= 'array()'
A collection of all the current headers for the object.
array()Details- Type
- array

object
$mailer= 'null'
The mailer object responsible for implementing the modMail methods.
nullDetails- Type
- object

\modX
$modx= 'null'
A reference to the modX instance communicating with this service instance.
nullDetails- Type
- \modX
Methods

__construct(
\modX $modx, array $attributes
=
array()
)
:
voidConstructs a new instance of the modMail class.
| Name | Type | Description |
|---|---|---|
| $modx | \modX | &$modx A reference to the modX instance |
| $attributes | array | An array of attributes to assign to the new mail instance |

_getMailer(
)
:
booleanGet 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.}
| Type | Description |
|---|---|
| boolean | Indicates if the mailer class was instantiated successfully. |
- Abstract
- Access
- protected

address(
string $type, string $email, string $name
=
''
)
:
booleanAdd a new recipient email address to one of the valid address type buckets.
| Name | Type | Description |
|---|---|---|
| $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. |
| Type | Description |
|---|---|
| boolean | Indicates if the address was set/unset successfully. |
- Access
- public

attach(
string $file
)
:
voidAttach a file to the attachments queue.
| Name | Type | Description |
|---|---|---|
| $file | string | The absolute path to the file |
- Access
- public

get(
string $key
)
:
mixedGets a reference to an attribute of the mail object.
| Name | Type | Description |
|---|---|---|
| $key | string | The attribute key. |
| Type | Description |
|---|---|
| mixed | A reference to the attribute, or null if no attribute value is set for the key. |
- Access
- public

getDefaultAttributes(
array $attributes
=
array()
)
:
arrayGets the default attributes for modMail based on system settings
| Name | Type | Description |
|---|---|---|
| $attributes | array | An optional array of default attributes to override with |
| Type | Description |
|---|---|
| array | An array of default attributes |

header(
string $header
)
:
booleanAdds a header to the mailer
| Name | Type | Description |
|---|---|---|
| $header | string | The HTTP header to send. |
| Type | Description |
|---|---|
| boolean | True if the header is valid and is set. |
- Access
- public

reset(
array $attributes
=
array()
)
:
voidReset the mail service, clearing addresses and attributes.
| Name | Type | Description |
|---|---|---|
| $attributes | array | An optional array of attributes to apply after reset. |
- Access
- public

send(
array $attributes
=
array()
)
:
booleanSend an email setting any supplied attributes before sending.
{@internal You should implement the rest of this method in a derivative class.}
| Name | Type | Description |
|---|---|---|
| $attributes | array | Attributes to override any existing attributes before sending. |
| Type | Description |
|---|---|
| boolean | Indicates if the email was sent successfully. |
- Abstract
- Access
- public

set(
string $key, mixed $value
)
:
voidSets 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}
| Name | Type | Description |
|---|---|---|
| $key | string | The key of the attribute to set. |
| $value | mixed | The value of the attribute. |
- Abstract
- Access
- public