Mailer
in package
Simple Email templating. Uses the phpmailer for sending
Tags
Table of Contents
Constants
- CONTENT_MARK = 'contentMail'
- CONTENT_SUBJECT = 'contentSubject'
Properties
- $setFrom : bool
- $body : string|null
- $db : SQL
- $log : Logger|null
- $mailer : PHPMailer
- $template : array<string, string>|null
Methods
- __construct() : mixed
- addAttachment() : void
- Add message attachment
- addStringAttachment() : void
- Add attachment in base64 format
- exist() : bool
- Checks if the template is loaded and possibility to send mail
- getEml() : string
- getHtml() : string
- Fill template with data
- getParam() : string|null
- Returns template parameter
- loadTemplate() : bool
- Load template
- replace() : string
- Insert variables into template
- reset() : void
- Reset phpmailer content
- send() : bool|null
- Send email template with inserted data
- setBody() : void
- Set message text
- setBodyFile() : void
- Set message text from file
- anonymize() : string
- Remove parts of email address to be GDPR compliant for log
- anonymizeHide() : string
- Replace inside part of string
- createMailer() : bool
- Initialize phpmailer
Constants
CONTENT_MARK
public
string
CONTENT_MARK
= 'contentMail'
CONTENT_SUBJECT
public
string
CONTENT_SUBJECT
= 'contentSubject'
Properties
$setFrom
public
static bool
$setFrom
= true
Disable adding second envelope sender because sendmail_path property already contains a -f parameter
$body
protected
string|null
$body
= null
$db
protected
SQL
$db
$log
protected
Logger|null
$log
$mailer
protected
PHPMailer
$mailer
= null
$template
protected
array<string, string>|null
$template
= null
Methods
__construct()
public
__construct(SQL $db[, string|null $type = null ][, int|null $langId = null ][, Logger|null $log = null ]) : mixed
Parameters
addAttachment()
Add message attachment
public
addAttachment(array<string|int, string>|string $attachments[, string $name = '' ]) : void
Parameters
- $attachments : array<string|int, string>|string
- $name : string = ''
Tags
addStringAttachment()
Add attachment in base64 format
public
addStringAttachment(string $fileName, binary $data[, string $mime = '' ]) : void
Parameters
- $fileName : string
- $data : binary
- $mime : string = ''
Tags
exist()
Checks if the template is loaded and possibility to send mail
public
exist() : bool
Return values
boolgetEml()
public
getEml() : string
Tags
Return values
stringgetHtml()
Fill template with data
public
getHtml([array<string, string> $data = [] ]) : string
Parameters
- $data : array<string, string> = []
Return values
stringgetParam()
Returns template parameter
public
getParam(string $param) : string|null
Parameters
- $param : string
Return values
string|nullloadTemplate()
Load template
public
loadTemplate(string $type[, int|null $langId = null ][, bool $onlyAcive = true ]) : bool
Parameters
- $type : string
- $langId : int|null = null
- $onlyAcive : bool = true
Return values
boolreplace()
Insert variables into template
public
replace(string $template, array<string, string> $data) : string
Parameters
- $template : string
- $data : array<string, string>
Return values
stringreset()
Reset phpmailer content
public
reset() : void
send()
Send email template with inserted data
public
send([array<string, string> $data = [] ][, mixed $emails = [] ][, bool $mailAll = true ][, int $userId = 0 ]) : bool|null
Parameters
- $data : array<string, string> = []
- $emails : mixed = []
- $mailAll : bool = true
- $userId : int = 0
Tags
Return values
bool|nullsetBody()
Set message text
public
setBody(string $text) : void
Parameters
- $text : string
setBodyFile()
Set message text from file
public
setBodyFile(string $fileName) : void
Parameters
- $fileName : string
Tags
anonymize()
Remove parts of email address to be GDPR compliant for log
protected
anonymize(array<string|int, string> $mails) : string
Parameters
- $mails : array<string|int, string>
Return values
stringanonymizeHide()
Replace inside part of string
protected
anonymizeHide(string $string[, int $chars = 2 ][, string $new = '*' ]) : string
Parameters
- $string : string
- $chars : int = 2
- $new : string = '*'
Return values
stringcreateMailer()
Initialize phpmailer
protected
createMailer() : bool