IEMailTemplate
in
Interface IEMailTemplate
Interface to a class that allows to build HTML emails
Example:
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
Table of Contents
Methods
- 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|false $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|false = ''
-
Text of button in plain text version if empty the $text is used, if false none will be used
Tags
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
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 $plainIndent = 0 ]) : mixed
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 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
- $plainIndent : mixed = 0
Tags
addBodyText()
Adds a paragraph to the body of the email
public
addBodyText(string $text[, string|bool $plainText = '' ]) : mixed
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
Tags
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
This is an automatically sent email" will be used - $lang : string = null
-
Optional language to set the default footer in
Tags
addHeader()
Adds a header to the email
public
addHeader() : mixed
Tags
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
renderHtml()
Returns the rendered HTML email as string
public
renderHtml() : string
Tags
Return values
stringrenderSubject()
Returns the rendered email subject as string
public
renderSubject() : string
Tags
Return values
stringrenderText()
Returns the rendered plain text email as string
public
renderText() : string
Tags
Return values
stringsetSubject()
Sets the subject of the email
public
setSubject(string $subject) : mixed
Parameters
- $subject : string