Back to Joomla project (class list)

Class MailTemplate - list of methods

Email Templating Class
Package: Joomla\CMS\Mail
Copyright: (C) 2019 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Mail/MailTemplate.php
Project: Joomla

Method Summary

public
(mixed $templateId, mixed $language, \Joomla\CMS\Mail\Mail $mailer = null)

Constructor for the mail templating class
Parameters
  • string $templateId Id of the mail template.
  • string $language Language of the template to use.
  • \Joomla\CMS\Mail\Mail $mailer Mail object to send the mail with.
Since
  • 4.0.0
Show source code of this method: __construct Source Code

public void
(mixed $name, mixed $file)

Add an attachment to the mail
Parameters
  • string $name Filename of the attachment
  • string $file Either a filepath or filecontent
Returns
  • void
Since
  • 4.0.0
Show source code of this method: addAttachment Source Code

public void
(mixed $mail, mixed $name = null, mixed $type = 'to')

Adds recipients for this mail
Parameters
  • string $mail Mail address of the recipient
  • string $name Name of the recipient
  • string $type How should the recipient receive the mail? ('to', 'cc', 'bcc')
Returns
  • void
Since
  • 4.0.0
Show source code of this method: addRecipient Source Code

public void
(mixed $mail, mixed $name = '')

Set reply to for this mail
Parameters
  • string $mail Mail address to reply to
  • string $name Name
Returns
  • void
Since
  • 4.0.0
Show source code of this method: setReplyTo Source Code

public void
(mixed $data)

Add data to replace in the template
Parameters
  • array $data Associative array of strings to replace
Returns
  • void
Since
  • 4.0.0
Show source code of this method: addTemplateData Source Code

public bool
()

Render and send the mail
Returns
  • bool True on success
Since
  • 4.0.0
-
  • \Exception
  • \Joomla\CMS\Mail\Exception\MailDisabledException
  • \PHPMailer\PHPMailer\Exception
Show source code of this method: send Source Code

protected string
(mixed $text, mixed $tags)

Replace tags with their values recursively
Parameters
  • string $text The template to process
  • array $tags An associative array to replace in the template
Returns
  • string Rendered mail template
Since
  • 4.0.0
Show source code of this method: replaceTags Source Code

public static object|null
(mixed $key, mixed $language)

Get a specific mail template
Parameters
  • string $key Template identifier
  • string $language Language code of the template
Returns
  • object|null An object with the data of the mail, or null if the template not found in the db.
Since
  • 4.0.0
Show source code of this method: getTemplate Source Code

public static bool
(mixed $key, mixed $subject, mixed $body, mixed $tags, mixed $htmlbody = '')

Insert a new mail template into the system
Parameters
  • string $key Mail template key
  • string $subject A default subject (normally a translatable string)
  • string $body A default body (normally a translatable string)
  • array $tags Associative array of tags to replace
  • string $htmlbody A default htmlbody (normally a translatable string)
Returns
  • bool True on success, false on failure
Since
  • 4.0.0
Show source code of this method: createTemplate Source Code

public static bool
(mixed $key, mixed $subject, mixed $body, mixed $tags, mixed $htmlbody = '')

Update an existing mail template
Parameters
  • string $key Mail template key
  • string $subject A default subject (normally a translatable string)
  • string $body A default body (normally a translatable string)
  • array $tags Associative array of tags to replace
  • string $htmlbody A default htmlbody (normally a translatable string)
Returns
  • bool True on success, false on failure
Since
  • 4.0.0
Show source code of this method: updateTemplate Source Code

public static bool
(mixed $key)

Method to delete a mail template
Parameters
  • string $key The key of the mail template
Returns
  • bool True on success, false on failure
Since
  • 4.0.0
Show source code of this method: deleteTemplate Source Code

protected string
(string $file, string $name)

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
Parameters
  • string $file Path to the file to be attached
  • string $name The file name to be used for the attachment
Returns
  • string The corrected file name for the attachment
Since
  • 4.0.0
Show source code of this method: getAttachmentName Source Code

Properties Summary

protected \Joomla\CMS\Mail\Mail
$mailer
Mailer object to send the actual mail.
Since
  • 4.0.0
protected string
$template_id
Identifier of the mail template.
Since
  • 4.0.0
protected string
$language
Language of the mail template.
protected string[]
$data
Since
  • 4.0.0
protected string[]
$attachments
Since
  • 4.0.0
protected \stdClass[]
$recipients
List of recipients of the email
Since
  • 4.0.0
protected \stdClass
$replyto
Reply To of the email
Since
  • 4.0.0

Tags Summary

Since
4.0.0