Documentation

CMail
in package

Class to manage the sending of emails. It needs phpmailer to be used.

Table of Contents

Properties

$mailer  : PHPMailer

Methods

__construct()  : mixed
Constructor for CMail.
AddAttachment()  : void
Add a file attached to the email
AddBCC()  : void
Adds an email address and name to send a copy to (the name will NOT appear to other recipients)
AddCC()  : void
Adds an email address and name to send a copy to (the name will also appear to other recipients)
Send()  : string
Send an email with all necessary parameters
SendFromtemplate()  : string
Send an email with all necessary parameters using a template
SetFrom()  : void
Set the email and the name of the sender
SetReplyTo()  : void
Set the email address and name to send any reply to

Properties

$mailer

protected PHPMailer $mailer

object

Methods

__construct()

Constructor for CMail.

public __construct() : mixed

Initializes PHPMailer with SMTP settings from configuration constants.

Tags
throws
Exception

If PHPMailer initialization fails.

AddAttachment()

Add a file attached to the email

public AddAttachment(string $filePath) : void
Parameters
$filePath : string

the path of file in the server

AddBCC()

Adds an email address and name to send a copy to (the name will NOT appear to other recipients)

public AddBCC(string $email[, string $name = '' ]) : void
Parameters
$email : string

email address to add the copy to the recipient

$name : string = ''

name to add the copy to the recipient (can be empty or not declared)

AddCC()

Adds an email address and name to send a copy to (the name will also appear to other recipients)

public AddCC(string $email[, string $name = '' ]) : void
Parameters
$email : string

email address to add the copy to the recipient

$name : string = ''

name to add the copy to the recipient (can be empty or not declared)

Send()

Send an email with all necessary parameters

public Send(string $email, string $name, string $subject, string $body_html[, string $body_text = '' ]) : string
Parameters
$email : string

email address to add the copy to the recipient

$name : string

name to add the copy to the recipient (can be empty or not declared)

$subject : string

The title of the email

$body_html : string

The body of the message in HTML format

$body_text : string = ''

The body of the message in plain text format

Return values
string —

the reply message after sending

SendFromtemplate()

Send an email with all necessary parameters using a template

public SendFromtemplate(string $email, string $name, string $template[, array<string, string>|null $replaces = null ]) : string
Parameters
$email : string

email address to add the copy to the recipient

$name : string

name to add the copy to the recipient (can be empty or not declared)

$template : string

the template with [TAGS] to change with relative parameters inside $replaces

$replaces : array<string, string>|null = null

associative array containing the list of values ​​that replace the template TAGS ([TAG]=>Value)

Return values
string —

the reply message after sending

SetFrom()

Set the email and the name of the sender

public SetFrom(string $email[, string $name = '' ]) : void
Parameters
$email : string

the email of sender

$name : string = ''

the name of sender (can be empty or not declared)

SetReplyTo()

Set the email address and name to send any reply to

public SetReplyTo(string $email[, string $name = '' ]) : void
Parameters
$email : string

the email address to reply to the email if necessary

$name : string = ''

the name to reply (can be empty or not declared)


        
On this page

Search results