MassMailerEmails extends MassMailerModel uses Parser
MassMailerEmails model
Table of Contents
Methods
| add() | Creates an email for the given job |
| getByJob() | Retrieves the email associated with the given job |
| getSample() | Generates a parsed sample subject, HTML, and text content of an email based on the given contact and email information |
| htmlToText() | Converts the given HTML to text if the given text contains no characters |
| send() | Sends the given email to the contact from the given task |
| validate() | Validates whether the given email fields are acceptable |
| validateUniqueEmail() | Validates that the given job is not associated with an email |
| getRules() | Retrieves the rules for validating email fields |
Methods
add()
Creates an email for the given job
public
add(int $job_id, array<string|int, mixed> $vars) : mixed
Parameters
- $job_id : int
-
The ID of the job
- $vars : array<string|int, mixed>
-
An array of input including:
- from_name The name of the sender
- from_address The email address of the sender
- subject The subject of the email
- text The text version of the email body
- html The HTML version of the email body
- log Whether or not to log the email when sent
Return values
mixed —The ID of the email created, or void on error
getByJob()
Retrieves the email associated with the given job
public
getByJob(int $job_id) : mixed
Parameters
- $job_id : int
-
The ID of the job
Return values
mixed —An stdClass object representing the email, or false if not found
getSample()
Generates a parsed sample subject, HTML, and text content of an email based on the given contact and email information
public
getSample(array<string|int, mixed> $email, stdClass $contact) : stdClass
Parameters
- $email : array<string|int, mixed>
-
An array containing the email content:
- subject The email subject
- html The email HTML content
- text The email text content
- $contact : stdClass
-
An stdClass object representing the contact
Return values
stdClass —An stdClass object containing:
- subject The email subject
- html The email HTML content
- text The email text content
htmlToText()
Converts the given HTML to text if the given text contains no characters
public
htmlToText(string $html[, string $text = '' ]) : string
Parameters
- $html : string
-
The HTML to convert to text
- $text : string = ''
-
The current text, if any
Return values
string —The HTML converted to text, or the original text given
send()
Sends the given email to the contact from the given task
public
send(stdClass $task, stdClass $email) : mixed
Parameters
- $task : stdClass
-
An stdClass object representing the mass mailer task
- contact_id The ID of the contact
- service_id The ID of the contact's service
- $email : stdClass
-
An stdClass object representing the mass mailer email
- from_name The email from name
- from_address The from email address
- subject The email's subject
- text The email's text copy
- html The email's HTML copy
- log Whether to log the email when sent
validate()
Validates whether the given email fields are acceptable
public
validate(array<string|int, mixed> $vars) : bool
Parameters
- $vars : array<string|int, mixed>
-
An array of email fields to validate
Return values
bool —True if the data is valid, or false otherwise
validateUniqueEmail()
Validates that the given job is not associated with an email
public
validateUniqueEmail(int $job_id) : bool
Parameters
- $job_id : int
-
The ID of the job
Return values
bool —True if the job does not have an email, or false otherwise
getRules()
Retrieves the rules for validating email fields
private
getRules([bool $require_job = true ]) : array<string|int, mixed>
Parameters
- $require_job : bool = true
-
True to validate the job, otherwise validates only email fields
Return values
array<string|int, mixed> —An array of input validation rules