Welcome to FrostSW!

FrostMVC PHP Framework

Documentation   |   Version

Mail

FrostMVC\Mail

use FrostMVC\Mail;

SMTP email sender built on PHPMailer.

Wraps PHPMailer with a simpler configuration API while preserving access to the underlying PHPMailer instance via getMail().

Methods

->__construct() —
->addAttachment()

Adds an attachment from a file path.

->addBCC()

Adds a BCC recipient.

->addCC()

Adds a CC recipient.

->addRecipient()

Adds a recipient email address.

->addReplyTo()

Adds a Reply-To address.

->getException()

Returns whether exceptions are thrown on send failure.

->getHost() —
->getMail()

Returns the underlying PHPMailer instance for advanced configuration.

->getPassword() —
->getPort() —
->getSecurity() —
->getSMTPAuth()

Returns whether SMTP authentication is enabled.

->getUsername() —
->send()

Sends the email using the configured SMTP settings. Debug output, when enabled, is written to the smtp.error log via Logs::write().

->setBody() —
->setDebug()

Sets the SMTP debug output level. Common values: SMTP::DEBUG_OFF (0), SMTP::DEBUG_CLIENT (1), SMTP::DEBUG_SERVER (2).

->setException()

Controls whether PHPMailer throws exceptions on errors.

->setHost() —
->setPassword() —
->setPort() —
->setSecurity()

Sets the encryption type.

->setSenderName() —
->setSMTPAuth()

Enables or disables SMTP authentication.

->setSMTPAutoTLS()

Enables or disables automatic TLS detection. Setting this to false prevents PHPMailer from upgrading to TLS when not required.

->setSubject() —
->setUsername() —

__construct()

$mail->__construct(bool $exception = false)

No description yet.

Parameters

$exception bool Default: false

addAttachment()

$mail->addAttachment($path, $name = '', $encoding = PHPMailer\PHPMailer\PHPMailer::ENCODING_BASE64, $type = '', $disposition = 'attachment')

Adds an attachment from a file path.

Parameters

$path string

Absolute path to the file.

$name string

Attachment filename shown to the recipient.

Default: ''
$encoding string

Content transfer encoding.

Default: PHPMailer\PHPMailer\PHPMailer::ENCODING_BASE64
$type string

MIME type.

Default: ''
$disposition string

'attachment' or 'inline'.

Default: 'attachment'

addBCC()

$mail->addBCC($email, $name = '')

Adds a BCC recipient.

Parameters

$email string
$name string

Optional display name.

Default: ''

addCC()

$mail->addCC($email, $name = '')

Adds a CC recipient.

Parameters

$email string
$name string

Optional display name.

Default: ''

addRecipient()

$mail->addRecipient($email, $name = '')

Adds a recipient email address.

Parameters

$email string
$name string

Optional display name.

Default: ''

addReplyTo()

$mail->addReplyTo($email, $name = '')

Adds a Reply-To address.

Parameters

$email string
$name string

Optional display name.

Default: ''

getException()

$mail->getException()

Returns whether exceptions are thrown on send failure.

Returns

bool

getHost()

$mail->getHost()

No description yet.

Returns

string SMTP hostname.

getMail()

$mail->getMail()

Returns the underlying PHPMailer instance for advanced configuration.

Returns

PHPMailer

getPassword()

$mail->getPassword()

No description yet.

Returns

string SMTP password.

getPort()

$mail->getPort()

No description yet.

Returns

int SMTP port number.

getSecurity()

$mail->getSecurity()

No description yet.

Returns

string Encryption type: PHPMailer::ENCRYPTION_STARTTLS or PHPMailer::ENCRYPTION_SMTPS.

getSMTPAuth()

$mail->getSMTPAuth()

Returns whether SMTP authentication is enabled.

Returns

bool

getUsername()

$mail->getUsername()

No description yet.

Returns

string SMTP username.

send()

$mail->send($showError = false)

Sends the email using the configured SMTP settings. Debug output, when enabled, is written to the smtp.error log via Logs::write().

Parameters

$showError int|false

SMTP debug level to enable during the send, or false to suppress.

Default: false

Returns

bool True on success, false on failure.

setBody()

$mail->setBody($message)

No description yet.

Parameters

$message string

HTML email body.

setDebug()

$mail->setDebug($debug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER)

Sets the SMTP debug output level. Common values: SMTP::DEBUG_OFF (0), SMTP::DEBUG_CLIENT (1), SMTP::DEBUG_SERVER (2).

Parameters

$debug int Default: PHPMailer\PHPMailer\SMTP::DEBUG_SERVER

setException()

$mail->setException($exception)

Controls whether PHPMailer throws exceptions on errors.

Parameters

$exception bool

setHost()

$mail->setHost($host)

No description yet.

Parameters

$host string

SMTP server hostname.

setPassword()

$mail->setPassword($password)

No description yet.

Parameters

$password string

SMTP authentication password.

setPort()

$mail->setPort($port)

No description yet.

Parameters

$port int

SMTP port (typically 465 for SMTPS, 587 for STARTTLS).

setSecurity()

$mail->setSecurity($security)

Sets the encryption type.

Parameters

$security string

PHPMailer::ENCRYPTION_STARTTLS or PHPMailer::ENCRYPTION_SMTPS.

setSenderName()

$mail->setSenderName($name)

No description yet.

Parameters

$name string

Display name of the sender.

setSMTPAuth()

$mail->setSMTPAuth($bool)

Enables or disables SMTP authentication.

Parameters

$bool bool

setSMTPAutoTLS()

$mail->setSMTPAutoTLS($bool)

Enables or disables automatic TLS detection. Setting this to false prevents PHPMailer from upgrading to TLS when not required.

Parameters

$bool bool

setSubject()

$mail->setSubject($subject)

No description yet.

Parameters

$subject string

Email subject line.

setUsername()

$mail->setUsername($username)

No description yet.

Parameters

$username string

SMTP authentication username (usually the sender address).

Generated from core/classes/Mail.php (FrostMVC ).