Ka Extensions for OpenCart 4

This documentation applies to Ka Extensions for OpenCart 4.x only. It is not compatible with OpenCart 3.

Mail
in component

Simplifies email submission. Builds emails from templates and language files and sends them with the store mail settings.

Table of Contents

Properties

Methods

__construct()  : mixed
Prepares an email: loads the language, creates the OpenCart mail object and loads store information and settings.
addAttachment()  : mixed
Adds a file attachment.
loadViewForLanguage()  : string
Renders a template for the mail language. First it tries the template with the '_<language code>' suffix (e.g. mail/order_de.twig), then the standard one (mail/order.twig).
send()  : bool
Renders the HTML and text templates and sends the email. Images are embedded or linked depending on the settings.
sendContent()  : bool
Sends an email wrapped with the common header and footer templates.

Properties

$data

public mixed $data

$images

public mixed $images

$language

public mixed $language

$mail

public mixed $mail

$sender

public mixed $sender

$store_config

public mixed $store_config

$config

protected mixed $config

$load

protected mixed $load

$log

protected mixed $log

$registry

protected mixed $registry

$request

protected mixed $request

$session

protected mixed $session

Methods

__construct()

Prepares an email: loads the language, creates the OpenCart mail object and loads store information and settings.

public __construct([mixed $language_code = null ][, mixed $store_id = 0 ]) : mixed

$language_code — language id or code (e.g. 'en-gb'); store default if empty. $store_id — store id.

Parameters
$language_code : mixed = null
$store_id : mixed = 0

addAttachment()

Adds a file attachment.

public addAttachment(mixed $filename[, mixed $name = '' ]) : mixed

$filename — path to the file. $name — attachment name; the file name if empty.

Parameters
$filename : mixed
$name : mixed = ''

loadViewForLanguage()

Renders a template for the mail language. First it tries the template with the '_<language code>' suffix (e.g. mail/order_de.twig), then the standard one (mail/order.twig).

public loadViewForLanguage(mixed $template, mixed $data) : string

$template — template name without extension. $data — template variables.

Parameters
$template : mixed
$data : mixed
Tags
throws
MailException

If the rendered content is empty.

Return values
string —

Rendered content.

send()

Renders the HTML and text templates and sends the email. Images are embedded or linked depending on the settings.

public send(mixed $from, mixed $to, mixed $subject, mixed $tpl[, mixed $extra = array() ]) : bool

$from — sender email; store email if empty. $to — recipient email. $subject — subject or language key. $tpl — template name without extension, e.g. extension/ka_extensions/product_warranty/mail/product_warranty_created. $extra — options: 'send_content' wraps the content with common header and footer, 'reply_to' sets Reply-To.

Parameters
$from : mixed
$to : mixed
$subject : mixed
$tpl : mixed
$extra : mixed = array()
Return values
bool —

True if sent, false if no template was found.

sendContent()

Sends an email wrapped with the common header and footer templates.

public sendContent(mixed $to, mixed $subject, mixed $tpl[, mixed $from = '' ][, mixed $extra = [] ]) : bool

$to — recipient email. $subject — subject or language key. $tpl — template name without extension. $from — sender email; store email if empty. $extra — additional options, see send().

Parameters
$to : mixed
$subject : mixed
$tpl : mixed
$from : mixed = ''
$extra : mixed = []
Return values
bool —

True if sent.


        
On this page

Search results