Mail
in package
Wrapper for PHPMailer class
Tags
Table of Contents
Properties
- $mail : mixed
- $msg_error : mixed
- $new_email : mixed
Methods
- addAttachment() : $this
- Adds an attachment to the email
- bcc() : $this
- Adds BCC (blind carbon copy) recipient(s) to the email
- cc() : $this
- Adds CC (carbon copy) recipient(s) to the email
- config() : void
- Configures the mailer with SMTP settings or PHP's mail() function
- from() : $this
- Sets the sender's email address and name
- get_error() : string
- Gets the last error message
- has_error() : bool
- Checks if there was an error in the last operation
- isHTML() : $this
- Sets whether the email is in HTML format
- load_template() : mixed
- Finds and loads the email template
- message() : $this
- Sets the email message body
- replyTo() : $this
- Sets the Reply-To address and name
- send() : mixed
- Sends the email
- subject() : $this
- Sets the email subject
- to() : mixed
- To accepts multiple email addresses and names separated by commas
Properties
public
mixed
$mail
= null
$msg_error
public
mixed
$msg_error
= ''
$new_email
public
mixed
$new_email
= false
Methods
addAttachment()
Adds an attachment to the email
public
addAttachment(string $path[, string $name = '' ]) : $this
Parameters
- $path : string
-
Full path to the file to attach
- $name : string = ''
-
Optional custom filename for the attachment
Return values
$this —Returns self for method chaining
bcc()
Adds BCC (blind carbon copy) recipient(s) to the email
public
bcc(string $address[, string $name = '' ]) : $this
Parameters
- $address : string
-
Single email or comma-separated list of email addresses
- $name : string = ''
-
Optional name(s) corresponding to the email address(es)
Return values
$this —Returns self for method chaining
cc()
Adds CC (carbon copy) recipient(s) to the email
public
cc(string $address[, string $name = '' ]) : $this
Parameters
- $address : string
-
Single email or comma-separated list of email addresses
- $name : string = ''
-
Optional name(s) corresponding to the email address(es)
Return values
$this —Returns self for method chaining
config()
Configures the mailer with SMTP settings or PHP's mail() function
public
config(bool $is_smtp[, string $username = '' ][, string $password = '' ][, string $host = '' ][, int $port = 465 ][, string $smtpSecure = PHPMailer::ENCRYPTION_SMTPS ]) : void
Parameters
- $is_smtp : bool
-
Whether to use SMTP (true) or PHP's mail() function (false)
- $username : string = ''
-
SMTP username
- $password : string = ''
-
SMTP password
- $host : string = ''
-
SMTP server hostname
- $port : int = 465
-
SMTP port number (default: 465 for SSL)
- $smtpSecure : string = PHPMailer::ENCRYPTION_SMTPS
-
Encryption type (default: PHPMailer::ENCRYPTION_SMTPS)
from()
Sets the sender's email address and name
public
from(string $from[, string $from_name = '' ]) : $this
Parameters
- $from : string
-
Sender's email address
- $from_name : string = ''
-
Optional sender's name
Return values
$this —Returns self for method chaining
get_error()
Gets the last error message
public
get_error() : string
Return values
string —The last error message, or an empty string if no error occurred
has_error()
Checks if there was an error in the last operation
public
has_error() : bool
Return values
bool —True if there was an error, false otherwise
isHTML()
Sets whether the email is in HTML format
public
isHTML([bool $is_html = false ]) : $this
Parameters
- $is_html : bool = false
-
Whether the email is in HTML format (default: false)
Return values
$this —Returns self for method chaining
load_template()
Finds and loads the email template
public
load_template(mixed $path[, mixed $args_data = [] ]) : mixed
Parameters
- $path : mixed
- $args_data : mixed = []
message()
Sets the email message body
public
message(string $message) : $this
Parameters
- $message : string
-
The email message body (HTML or plain text)
Return values
$this —Returns self for method chaining
replyTo()
Sets the Reply-To address and name
public
replyTo(string $reply_to[, string $reply_to_name = '' ]) : $this
Parameters
- $reply_to : string
-
Reply-to email address
- $reply_to_name : string = ''
-
Optional reply-to name
Return values
$this —Returns self for method chaining
send()
Sends the email
public
send() : mixed
subject()
Sets the email subject
public
subject(string $subject) : $this
Parameters
- $subject : string
-
The email subject line
Return values
$this —Returns self for method chaining
to()
To accepts multiple email addresses and names separated by commas
public
to(string $address[, string $name = '' ]) : mixed
Parameters
- $address : string
- $name : string = ''