core/model/modx/mail/modphpmailer.class.php
This file contains the PHPMailer implementation of the modMail email service.
- Package
- modx
- Subpackage
\modPHPMailer
PHPMailer implementation of the modMail service.
- Parent(s)
- \modMail
Constants

MAIL_BODY
= 'mail_body'
- Const
- An option for setting the mail body
- Inherited_from
- \modMail::MAIL_BODY

MAIL_BODY_TEXT
= 'mail_body_text'
- Const
- An option for setting the mail body text
- Inherited_from
- \modMail::MAIL_BODY_TEXT

MAIL_CHARSET
= 'mail_charset'
- Const
- An option for setting the mail charset
- Inherited_from
- \modMail::MAIL_CHARSET

MAIL_CONTENT_TYPE
= 'mail_content_type'
- Const
- An option for setting the mail content type
- Inherited_from
- \modMail::MAIL_CONTENT_TYPE

MAIL_ENCODING
= 'mail_encoding'
- Const
- An option for setting the mail encoding
- Inherited_from
- \modMail::MAIL_ENCODING

MAIL_ENGINE
= 'mail_engine'
- Const
- An option for setting the mail engine
- Inherited_from
- \modMail::MAIL_ENGINE

MAIL_ENGINE_PATH
= 'mail_engine_path'
- Const
- An option for setting the mail engine path
- Inherited_from
- \modMail::MAIL_ENGINE_PATH

MAIL_ERROR_INFO
= 'mail_error_info'
- Const
- An option for setting the mail error information
- Inherited_from
- \modMail::MAIL_ERROR_INFO

MAIL_FROM
= 'mail_from'
- Const
- An option for setting the mail From address
- Inherited_from
- \modMail::MAIL_FROM

MAIL_FROM_NAME
= 'mail_from_name'
- Const
- An option for setting the mail From name
- Inherited_from
- \modMail::MAIL_FROM_NAME

MAIL_HOSTNAME
= 'mail_hostname'
- Const
- An option for setting the mail hostname
- Inherited_from
- \modMail::MAIL_HOSTNAME

MAIL_LANGUAGE
= 'mail_language'
- Const
- An option for setting the mail language
- Inherited_from
- \modMail::MAIL_LANGUAGE

MAIL_PRIORITY
= 'mail_priority'
- Const
- An option for setting the mail priority header
- Inherited_from
- \modMail::MAIL_PRIORITY

MAIL_READ_TO
= 'mail_read_to'
- Const
- An option for setting the mail read to header
- Inherited_from
- \modMail::MAIL_READ_TO

MAIL_SENDER
= 'mail_sender'
- Const
- An option for setting the mail sender
- Inherited_from
- \modMail::MAIL_SENDER

MAIL_SERVICE
= 'mail_service'
- Const
- An option for setting the mail service
- Inherited_from
- \modMail::MAIL_SERVICE

MAIL_SMTP_AUTH
= 'mail_smtp_auth'
- Const
- An option for setting the mail SMTP auth type
- Inherited_from
- \modMail::MAIL_SMTP_AUTH

MAIL_SMTP_HELO
= 'mail_smtp_helo'
- Const
- An option for setting the mail SMTP HELO boolean
- Inherited_from
- \modMail::MAIL_SMTP_HELO

MAIL_SMTP_HOSTS
= 'mail_smtp_hosts'
- Const
- An option for setting the mail SMTP hosts
- Inherited_from
- \modMail::MAIL_SMTP_HOSTS

MAIL_SMTP_KEEPALIVE
= 'mail_smtp_keepalive'
- Const
- An option for setting the mail SMTP Keep-Alive boolean
- Inherited_from
- \modMail::MAIL_SMTP_KEEPALIVE

MAIL_SMTP_PASS
= 'mail_smtp_pass'
- Const
- An option for setting the mail SMTP password
- Inherited_from
- \modMail::MAIL_SMTP_PASS

MAIL_SMTP_PORT
= 'mail_smtp_port'
- Const
- An option for setting the mail SMTP port
- Inherited_from
- \modMail::MAIL_SMTP_PORT

MAIL_SMTP_PREFIX
= 'mail_smtp_prefix'
- Const
- An option for setting the mail SMTP prefix
- Inherited_from
- \modMail::MAIL_SMTP_PREFIX

MAIL_SMTP_SINGLE_TO
= 'mail_smtp_single_to'
- Const
- An option for setting the mail SMTP Single-To option
- Inherited_from
- \modMail::MAIL_SMTP_SINGLE_TO

MAIL_SMTP_TIMEOUT
= 'mail_smtp_timeout'
- Const
- An option for setting the mail SMTP timeout
- Inherited_from
- \modMail::MAIL_SMTP_TIMEOUT

MAIL_SMTP_USER
= 'mail_smtp_user'
- Const
- An option for setting the mail SMTP username
- Inherited_from
- \modMail::MAIL_SMTP_USER

MAIL_SUBJECT
= 'mail_subject'
- Const
- An option for setting the mail subject
- Inherited_from
- \modMail::MAIL_SUBJECT
Properties


array
$addresses= 'array(
'to' => array(),
'cc' => array(),
'bcc' => array(),
'reply-to' => array(),
)'
array(
'to' => array(),
'cc' => array(),
'bcc' => array(),
'reply-to' => array(),
)
Details- Type
- array
- Inherited_from
- \modMail::$$addresses


array
$attributes= 'array()'
A collection of attributes defining all of the details of email communication.
Inherited from: \modMail::$$attributesarray()
Details- Type
- array
- Inherited_from
- \modMail::$$attributes


object
$mailer= 'null'
The mailer object responsible for implementing the modMail methods.
Inherited from: \modMail::$$mailernull
Details- Type
- object
- Inherited_from
- \modMail::$$mailer


\modX
$modx= 'null'
A reference to the modX instance communicating with this service instance.
Inherited from: \modMail::$$modxnull
Details- Type
- \modX
- Inherited_from
- \modMail::$$modx
Methods


__construct(
\modX $modx, array $attributes
=
array()
)
:
\modPHPMailer
Constructs a new instance of the modPHPMailer class.
Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX instance |
$attributes | array | An array of attributes for the instance |
Type | Description |
---|---|
\modPHPMailer |


_getMailer(
)
:
boolean
Loads the PHPMailer object used to send the emails in this implementation.
{@internal Implement this function in derivatives and call it in the constructor after all other dependencies have been satisfied.}
Type | Description |
---|---|
boolean | True if the mailer class was successfully loaded |


address(
string $type, string $email, string $name
=
''
)
:
boolean
Adds an address to the mailer
Name | Type | Description |
---|---|---|
$type | string | The type of address (to, reply-to, bcc, cc) |
string | The email address to address to |
|
$name | string | The name of the email address |
Type | Description |
---|---|
boolean | True if was addressed |


attach(
mixed $file, string $name
=
'', string $encoding
=
'base64', string $type
=
'application/octet-stream'
)
:
void
Attaches a file to the mailer.
Name | Type | Description |
---|---|---|
$file | mixed | The file to attach |
$name | string | The name of the file to attach as |
$encoding | string | The encoding of the attachment |
$type | string | The header type of the attachment |


get(
string $key
)
:
mixed
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()
)
:
array
Gets the default attributes for modMail based on system settings
Inherited from: \modMail::getDefaultAttributes()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
)
:
boolean
Adds a custom header to the mailer
Name | Type | Description |
---|---|---|
$header | string | The header to set |
Type | Description |
---|---|
boolean | True if the header was successfully set |


reset(
array $attributes
=
array()
)
:
void
Resets all PHPMailer attributes, including recipients and attachments.
Name | Type | Description |
---|---|---|
$attributes | array | An array of attributes to pass when resetting |


send(
array $attributes
=
array()
)
:
boolean
Send the email, applying any attributes to the mailer before sending.
{@internal You should implement the rest of this method in a derivative class.}
Name | Type | Description |
---|---|---|
$attributes | array | An array of attributes to pass when sending |
Type | Description |
---|---|
boolean | True if the email was successfully sent |


set(
string $key, mixed $value
)
:
void
Sets a PHPMailer attribute corresponding to the modX::MAIL_* constants or a custom key.
{@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 attribute key to set |
$value | mixed | The value to set |