EMailTemplate

class OC\Mail\EMailTemplate
Class EMailTemplate
addBodyText and addBodyButtonGroup automatically opens the body
addFooter, renderHtml, renderText automatically closes the body and the HTML if opened
Source:lib/private/Mail/EMailTemplate.php#55
Implements:OCP\Mail\IEMailTemplate

Properties

protected static property OC\Mail\EMailTemplate::$themingDefaults
Source:lib/private/Mail/EMailTemplate.php#57
Type:\OCP\Defaults
protected static property OC\Mail\EMailTemplate::$urlGenerator
Source:lib/private/Mail/EMailTemplate.php#59
Type:\OCP\IURLGenerator
protected static property OC\Mail\EMailTemplate::$l10nFactory
Source:lib/private/Mail/EMailTemplate.php#61
Type:\OCP\L10N\IFactory
protected static property OC\Mail\EMailTemplate::$emailId
Source:lib/private/Mail/EMailTemplate.php#63
Type:string
protected static property OC\Mail\EMailTemplate::$data
Source:lib/private/Mail/EMailTemplate.php#65
Type:array
protected static property OC\Mail\EMailTemplate::$subject
Source:lib/private/Mail/EMailTemplate.php#68
Type:string
protected static property OC\Mail\EMailTemplate::$htmlBody
Source:lib/private/Mail/EMailTemplate.php#70
Type:string
protected static property OC\Mail\EMailTemplate::$plainBody
Source:lib/private/Mail/EMailTemplate.php#72
Type:string
protected static property OC\Mail\EMailTemplate::$headerAdded
Source:lib/private/Mail/EMailTemplate.php#74
Type:bool indicated if the footer is added
protected static property OC\Mail\EMailTemplate::$bodyOpened
Source:lib/private/Mail/EMailTemplate.php#76
Type:bool indicated if the body is already opened
protected static property OC\Mail\EMailTemplate::$bodyListOpened
Source:lib/private/Mail/EMailTemplate.php#78
Type:bool indicated if there is a list open in the body
protected static property OC\Mail\EMailTemplate::$footerAdded
Source:lib/private/Mail/EMailTemplate.php#80
Type:bool indicated if the footer is added
protected static property OC\Mail\EMailTemplate::$head
Source:lib/private/Mail/EMailTemplate.php#82
protected static property OC\Mail\EMailTemplate::$tail
Source:lib/private/Mail/EMailTemplate.php#100
protected static property OC\Mail\EMailTemplate::$header
Source:lib/private/Mail/EMailTemplate.php#112
protected static property OC\Mail\EMailTemplate::$heading
Source:lib/private/Mail/EMailTemplate.php#145
protected static property OC\Mail\EMailTemplate::$bodyBegin
Source:lib/private/Mail/EMailTemplate.php#164
protected static property OC\Mail\EMailTemplate::$bodyText
Source:lib/private/Mail/EMailTemplate.php#174
protected static property OC\Mail\EMailTemplate::$listBegin
Source:lib/private/Mail/EMailTemplate.php#194
protected static property OC\Mail\EMailTemplate::$listItem
Source:lib/private/Mail/EMailTemplate.php#202
protected static property OC\Mail\EMailTemplate::$listEnd
Source:lib/private/Mail/EMailTemplate.php#214
protected static property OC\Mail\EMailTemplate::$buttonGroup
Source:lib/private/Mail/EMailTemplate.php#222
protected static property OC\Mail\EMailTemplate::$button
Source:lib/private/Mail/EMailTemplate.php#275
protected static property OC\Mail\EMailTemplate::$bodyEnd
Source:lib/private/Mail/EMailTemplate.php#315
protected static property OC\Mail\EMailTemplate::$footer
Source:lib/private/Mail/EMailTemplate.php#326

Methods

public OC\Mail\EMailTemplate::__construct($themingDefaults, $urlGenerator, $l10nFactory, $emailId, $data)
Source:lib/private/Mail/EMailTemplate.php#352
public OC\Mail\EMailTemplate::setSubject($subject)
Sets the subject of the email
Source:

lib/private/Mail/EMailTemplate.php#370

Parameters:
  • $subject (string)
public OC\Mail\EMailTemplate::addHeader()
Adds a header to the email
Source:lib/private/Mail/EMailTemplate.php#377
public OC\Mail\EMailTemplate::addHeading($title, $plainTitle="")
Adds a heading to the email
Source:

lib/private/Mail/EMailTemplate.php#394

Parameters:
  • $title (string)
  • $plainTitle (string | bool) Title that is used in the plain text email

if empty the $title is used, if false none will be used

protected OC\Mail\EMailTemplate::ensureBodyIsOpened()
Open the HTML body when it is not already
Source:lib/private/Mail/EMailTemplate.php#411
public OC\Mail\EMailTemplate::addBodyText($text, $plainText="")
Adds a paragraph to the body of the email
Source:

lib/private/Mail/EMailTemplate.php#427

Parameters:
  • $text (string) Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
  • $plainText (string | bool) Text that is used in the plain text email

if empty the $text is used, if false none will be used

public OC\Mail\EMailTemplate::addBodyListItem($text, $metaInfo="", $icon="", $plainText="", $plainMetaInfo="", $plainIndent=0)
Adds a list item to the body of the email
Source:

lib/private/Mail/EMailTemplate.php#458

Parameters:
  • $text (string) Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
  • $metaInfo (string) Note: When $plainMetaInfo falls back to this, HTML is automatically escaped in the HTML email
  • $icon (string) Absolute path, must be 16*16 pixels
  • $plainText (string | bool) Text that is used in the plain text email

if empty or true the $text is used, if false none will be used * $plainMetaInfo (string | bool) Meta info that is used in the plain text email if empty or true the $metaInfo is used, if false none will be used

Since:

12.0.0

protected OC\Mail\EMailTemplate::ensureBodyListOpened()
Source:lib/private/Mail/EMailTemplate.php#508
protected OC\Mail\EMailTemplate::ensureBodyListClosed()
Source:lib/private/Mail/EMailTemplate.php#518
public OC\Mail\EMailTemplate::addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft="", $plainTextRight="")
Adds a button group of two buttons to the body of the email
Source:

lib/private/Mail/EMailTemplate.php#537

Parameters:
  • $textLeft (string) Text of left button; Note: When $plainTextLeft falls back to this, HTML is automatically escaped in the HTML email
  • $urlLeft (string) URL of left button
  • $textRight (string) Text of right button; Note: When $plainTextRight falls back to this, HTML is automatically escaped in the HTML email
  • $urlRight (string) URL of right button
  • $plainTextLeft (string) Text of left button that is used in the plain text version - if unset the $textLeft is used
  • $plainTextRight (string) Text of right button that is used in the plain text version - if unset the $textRight is used
public OC\Mail\EMailTemplate::addBodyButton($text, $url, $plainText="")
Adds a button to the body of the email
Source:

lib/private/Mail/EMailTemplate.php#577

Parameters:
  • $text (string) Text of button; Note: When $plainText falls back to this, HTML is automatically escaped in the HTML email
  • $url (string) URL of button
  • $plainText (string) Text of button in plain text version

if empty the $text is used, if false none will be used

Since:

12.0.0

protected OC\Mail\EMailTemplate::ensureBodyIsClosed()
Close the HTML body when it is open
Source:lib/private/Mail/EMailTemplate.php#604
public OC\Mail\EMailTemplate::addFooter($text="", $lang=null)
Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
Source:

lib/private/Mail/EMailTemplate.php#620

Parameters:
  • $text (string) If the text is empty the default “Name - Slogan<br>This is an automatically sent email” will be used
public OC\Mail\EMailTemplate::renderSubject()
Returns the rendered email subject as string
Source:lib/private/Mail/EMailTemplate.php#644
Returns:string
public OC\Mail\EMailTemplate::renderHtml()
Returns the rendered HTML email as string
Source:lib/private/Mail/EMailTemplate.php#653
Returns:string
public OC\Mail\EMailTemplate::renderText()
Returns the rendered plain text email as string
Source:lib/private/Mail/EMailTemplate.php#667
Returns:string