IEMailTemplate

interface OCP\Mail\IEMailTemplate
Interface IEMailTemplate
Interface to a class that allows to build HTML emails

Example:

<?php

$emailTemplate = new EMailTemplate($this->defaults, $this->urlGenerator, $this->l10n);

$emailTemplate->addHeader();
$emailTemplate->addHeading(‘Welcome aboard’);
$emailTemplate->addBodyText(‘Welcome to your Nextcloud account, you can add, protect, and share your data.’);

$emailTemplate->addBodyButtonGroup(
‘Install Client’, ‘https://nextcloud.com/install/#install-clients’
);

$emailTemplate->addFooter(‘Optional footer text’);

$htmlContent = $emailTemplate->renderHtml();
$plainContent = $emailTemplate->renderText();
Implemented by:OC\Mail\EMailTemplate
Source:lib/public/Mail/IEMailTemplate.php#60

Methods

public OCP\Mail\IEMailTemplate::setSubject($subject)
Sets the subject of the email
Source:

lib/public/Mail/IEMailTemplate.php#69

Parameters:
  • $subject (string)
Since:

13.0.0

public OCP\Mail\IEMailTemplate::addHeader()
Adds a header to the email
Source:lib/public/Mail/IEMailTemplate.php#76
Since:12.0.0
public OCP\Mail\IEMailTemplate::addHeading($title, $plainTitle="")
Adds a heading to the email
Source:

lib/public/Mail/IEMailTemplate.php#87

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

Since:

12.0.0

public OCP\Mail\IEMailTemplate::addBodyText($text, $plainText="")
Adds a paragraph to the body of the email
Source:

lib/public/Mail/IEMailTemplate.php#98

Parameters:
  • $plainText (string | bool) Text that is used in the plain text email

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

Since:

12.0.0

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

lib/public/Mail/IEMailTemplate.php#113

Parameters:
  • $icon (string) Absolute path, must be 16*16 pixels
  • $plainText (string | bool) Text that is used in the plain text email

if empty 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 the $metaInfo is used, if false none will be used

Since:

12.0.0

public OCP\Mail\IEMailTemplate::addBodyButtonGroup($textLeft, $urlLeft, $textRight, $urlRight, $plainTextLeft="", $plainTextRight="")
Adds a button group of two buttons to the body of the email
Source:

lib/public/Mail/IEMailTemplate.php#127

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 empty the $textLeft is used
  • $plainTextRight (string) Text of right button that is used in the plain text version - if empty the $textRight is used
Since:

12.0.0

public OCP\Mail\IEMailTemplate::addBodyButton($text, $url, $plainText="")
Adds a button to the body of the email
Source:

lib/public/Mail/IEMailTemplate.php#139

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

public OCP\Mail\IEMailTemplate::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/public/Mail/IEMailTemplate.php#149

Parameters:
  • $text (string) If the text is empty the default “Name - Slogan<br>This is an automatically sent email” will be used
  • $lang (string) Optional language to set the default footer in
Since:

12.0.0

public OCP\Mail\IEMailTemplate::renderSubject()
Returns the rendered email subject as string
Source:lib/public/Mail/IEMailTemplate.php#158
Returns:string
Since:13.0.0
public OCP\Mail\IEMailTemplate::renderHtml()
Returns the rendered HTML email as string
Source:lib/public/Mail/IEMailTemplate.php#167
Returns:string
Since:12.0.0
public OCP\Mail\IEMailTemplate::renderText()
Returns the rendered plain text email as string
Source:lib/public/Mail/IEMailTemplate.php#176
Returns:string
Since:12.0.0