Nextcloud PHP API (stable18)

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( 'Set your password', 'https://example.org/resetPassword/q1234567890qwertz', 'Install Client', 'https://nextcloud.com/install/#install-clients' );

$emailTemplate->addFooter('Optional footer text');

$htmlContent = $emailTemplate->renderHtml(); $plainContent = $emailTemplate->renderText();

Tags
since
12.0.0

Table of Contents

addBodyButton()  : mixed
Adds a button to the body of the email
addBodyButtonGroup()  : mixed
Adds a button group of two buttons to the body of the email
addBodyListItem()  : mixed
Adds a list item to the body of the email
addBodyText()  : mixed
Adds a paragraph to the body of the email
addFooter()  : mixed
Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
addHeader()  : mixed
Adds a header to the email
addHeading()  : mixed
Adds a heading to the email
renderHtml()  : string
Returns the rendered HTML email as string
renderSubject()  : string
Returns the rendered email subject as string
renderText()  : string
Returns the rendered plain text email as string
setSubject()  : mixed
Sets the subject of the email

Methods

addBodyButton()

Adds a button to the body of the email

public addBodyButton(string $text, string $url[, string $plainText = '' ]) : mixed
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

Tags
since
12.0.0
Return values
mixed

addBodyButtonGroup()

Adds a button group of two buttons to the body of the email

public addBodyButtonGroup(string $textLeft, string $urlLeft, string $textRight, string $urlRight[, string $plainTextLeft = '' ][, string $plainTextRight = '' ]) : mixed
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

Tags
since
12.0.0
Return values
mixed

addBodyListItem()

Adds a list item to the body of the email

public addBodyListItem(string $text[, string $metaInfo = '' ][, string $icon = '' ][, string|bool $plainText = '' ][, string|bool $plainMetaInfo = '' ]) : mixed
Parameters
$text : string
$metaInfo : string = ''
$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

Tags
since
12.0.0
Return values
mixed

addBodyText()

Adds a paragraph to the body of the email

public addBodyText(string $text[, string|bool $plainText = '' ]) : mixed
Parameters
$text : string
$plainText : string|bool = ''

Text that is used in the plain text email if empty the $text is used, if false none will be used

Tags
since
12.0.0
Return values
mixed

addFooter()

Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email

public addFooter([string $text = '' ][, string $lang = null ]) : mixed
Parameters
$text : string = ''

If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used

$lang : string = null

Optional language to set the default footer in

Tags
since
12.0.0
Return values
mixed

addHeader()

Adds a header to the email

public addHeader() : mixed
Tags
since
12.0.0
Return values
mixed

addHeading()

Adds a heading to the email

public addHeading(string $title[, string|bool $plainTitle = '' ]) : mixed
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

Tags
since
12.0.0
Return values
mixed

renderHtml()

Returns the rendered HTML email as string

public renderHtml() : string
Tags
since
12.0.0
Return values
string

renderSubject()

Returns the rendered email subject as string

public renderSubject() : string
Tags
since
13.0.0
Return values
string

renderText()

Returns the rendered plain text email as string

public renderText() : string
Tags
since
12.0.0
Return values
string

setSubject()

Sets the subject of the email

public setSubject(string $subject) : mixed
Parameters
$subject : string
Tags
since
13.0.0
Return values
mixed

Search results