MailTemplate
Email Templating Class
since |
4.0.0 |
---|---|
package |
Joomla CMS |
Methods
__construct
Constructor for the mail templating class
__construct( templateId, language, \Joomla\CMS\Mail\Mail mailer = null) :
since |
4.0.0 |
---|
Arguments
- templateId
string
Id of the mail template.- language
string
Language of the template to use.- mailer
Mail
Mail object to send the mail with.
Response
mixed
addAttachment
Add an attachment to the mail
addAttachment( name, file) :
since |
4.0.0 |
---|
Arguments
- name
string
Filename of the attachment- file
string
Either a filepath or filecontent
Response
void
addRecipient
Adds recipients for this mail
addRecipient( mail, name = null, type = 'to') :
since |
4.0.0 |
---|
Arguments
string
Mail address of the recipient- name
string
Name of the recipient- type
string
How should the recipient receive the mail? ('to', 'cc', 'bcc')
Response
void
addTemplateData
Add data to replace in the template
addTemplateData(mixed||string|int data, plain = false) :
since |
4.0.0 |
---|
Arguments
- data
array<string|int, mixed>
Associative array of strings to replace- plain
bool
Only use the data for plain-text emails.
Response
void
addUnsafeTags
Mark tags as unsafe to ensure escaping in HTML mails
addUnsafeTags(mixed||string|int tags) :
since |
5.1.3 |
---|
Arguments
- tags
array<string|int, mixed>
Tag names
Response
void
createTemplate
Insert a new mail template into the system
createTemplate( key, subject, body, mixed||string|int tags, htmlbody = '') :
since |
4.0.0 |
---|
Arguments
- key
string
Mail template key- subject
string
A default subject (normally a translatable string)- body
string
A default body (normally a translatable string)- tags
array<string|int, mixed>
Associative array of tags to replace- htmlbody
string
A default htmlbody (normally a translatable string)
Response
bool
True on success, false on failure
deleteTemplate
Method to delete a mail template
deleteTemplate( key) :
since |
4.0.0 |
---|
Arguments
- key
string
The key of the mail template
Response
bool
True on success, false on failure
getAttachmentName
Check and if necessary fix the file name of an attachment so that the attached file has the same extension as the source file, and not a different file extension
getAttachmentName( file, name) :
since |
4.0.0 |
---|
Arguments
- file
string
Path to the file to be attached- name
string
The file name to be used for the attachment
Response
string
The corrected file name for the attachment
getTemplate
Get a specific mail template
getTemplate( key, language) : object|null
since |
4.0.0 |
---|
Arguments
- key
string
Template identifier- language
string
Language code of the template
Response
object|null
An object with the data of the mail, or null if the template not found in the db.
replaceTags
Replace tags with their values recursively
replaceTags( text, mixed||string|int tags, isHtml = false) :
since |
4.0.0 |
---|
Arguments
- text
string
The template to process- tags
array<string|int, mixed>
An associative array to replace in the template- isHtml
bool
Is the text an HTML text and requires escaping
Response
string
Rendered mail template
send
Render and send the mail
send() :
setReplyTo
Set reply to for this mail
setReplyTo( mail, name = '') :
since |
4.0.0 |
---|
Arguments
string
Mail address to reply to- name
string
Name
Response
void
updateTemplate
Update an existing mail template
updateTemplate( key, subject, body, mixed||string|int tags, htmlbody = '') :
since |
4.0.0 |
---|
Arguments
- key
string
Mail template key- subject
string
A default subject (normally a translatable string)- body
string
A default body (normally a translatable string)- tags
array<string|int, mixed>
Associative array of tags to replace- htmlbody
string
A default htmlbody (normally a translatable string)
Response
bool
True on success, false on failure
Properties
template_id
Identifier of the mail template.
since |
4.0.0 |
---|
Type(s)
string
language
Language of the mail template.
Type(s)
string
data
since |
4.0.0 |
---|
Type(s)
array<string|int, string>
plain_data
since |
5.1.0 |
---|
Type(s)
array<string|int, string>
unsafe_tags
since |
5.1.3 |
---|
Type(s)
array<string|int, string>
attachments
since |
4.0.0 |
---|
Type(s)
array<string|int, string>
recipients
List of recipients of the email
since |
4.0.0 |
---|
Type(s)
array<string|int, stdClass>
replyto
Reply To of the email
since |
4.0.0 |
---|
Type(s)
stdClass