Click here if you want to read this article for the latest version.
Piwik\
Class for sending mails
Methods
The class defines the following methods:
__construct()setFrom()— Sets the sender.setDefaultFromPiwik()— Sets the default sendergetFrom()— Returns the address the mail will be sent fromgetFromName()— Returns the address the mail will be sent fromsetWrappedHtmlBody()setBodyHtml()— Sets the HTML part of the mailsetBodyText()— Sets the text part of the mail.getBodyHtml()— Returns html content of the mailgetBodyText()— Returns text content of the mailsetSubject()— Sets the subject of the mailgetSubject()— Return the subject of the mailaddTo()— Adds a recipientgetRecipients()— Returns the list of recipientsaddBcc()— Add Bcc addressgetBccs()— Returns the list of bcc addressesclearAllRecipients()— Removes all recipients and bccs from the listaddReplyTo()— Add Reply-To addresssetReplyTo()— Sets the reply to address (all previously added addresses will be removed)getReplyTos()— Returns the list of reply to addressesaddAttachment()getAttachments()send()— Sends the mailsafeSend()— If the send email process throws an exception, we catch it and log itsetSmtpDebug()— Enables SMTP debuggingisSmtpDebugEnabled()— Returns whether SMTP debugging is enabled or notgetMailHost()— Returns the hostname mails will be sent fromsanitiseString()— Replaces characters known to appear incorrectly in some email clients
__construct()
Signature
setFrom()
Sets the sender.
Signature
- It accepts the following parameter(s):
$email(string) — Email address of the sender.$name(null|string) — Name of the sender.
- It does not return anything or a mixed result.
setDefaultFromPiwik()
Sets the default sender
Signature
- It does not return anything or a mixed result.
- It throws one of the following exceptions:
DI\NotFoundException
getFrom()
Returns the address the mail will be sent from
Signature
- It returns a
stringvalue.
getFromName()
Returns the address the mail will be sent from
Signature
- It returns a
stringvalue.
setWrappedHtmlBody()
Signature
It accepts the following parameter(s):
$body(View|string) —
It does not return anything or a mixed result.
- It throws one of the following exceptions:
DI\NotFoundException
setBodyHtml()
Sets the HTML part of the mail
Signature
It accepts the following parameter(s):
$html
It does not return anything or a mixed result.
setBodyText()
Sets the text part of the mail.
If bodyHtml is set, this will be used as alternative text part
Signature
It accepts the following parameter(s):
$txt
It does not return anything or a mixed result.
getBodyHtml()
Returns html content of the mail
Signature
- It returns a
stringvalue.
getBodyText()
Returns text content of the mail
Signature
- It returns a
stringvalue.
setSubject()
Sets the subject of the mail
Signature
It accepts the following parameter(s):
$subject
It does not return anything or a mixed result.
getSubject()
Return the subject of the mail
Signature
- It returns a
stringvalue.
addTo()
Adds a recipient
Signature
It accepts the following parameter(s):
$address(string) —$name(string) —
It does not return anything or a mixed result.
getRecipients()
Returns the list of recipients
Signature
- It returns a
arrayvalue.
addBcc()
Add Bcc address
Signature
It accepts the following parameter(s):
$email(string) —$name(string) —
It does not return anything or a mixed result.
getBccs()
Returns the list of bcc addresses
Signature
- It returns a
arrayvalue.
clearAllRecipients()
Removes all recipients and bccs from the list
Signature
- It does not return anything or a mixed result.
addReplyTo()
Add Reply-To address
Signature
It accepts the following parameter(s):
$email(string) —$name(string) —
It does not return anything or a mixed result.
setReplyTo()
Sets the reply to address (all previously added addresses will be removed)
Signature
It accepts the following parameter(s):
$email(string) —$name(string) —
It does not return anything or a mixed result.
getReplyTos()
Returns the list of reply to addresses
Signature
- It returns a
arrayvalue.
addAttachment()
Signature
It accepts the following parameter(s):
$body$mimeType$filename$cid
It does not return anything or a mixed result.
getAttachments()
Signature
- It does not return anything or a mixed result.
send()
Sends the mail
Signature
- Returns:
bool|null— returns null if sending the mail was aborted by the Mail.send event - It throws one of the following exceptions:
DI\NotFoundException
safeSend()
If the send email process throws an exception, we catch it and log it
Signature
- It returns a
voidvalue. - It throws one of the following exceptions:
DI\NotFoundExceptionDI\DependencyException
setSmtpDebug()
Enables SMTP debugging
Signature
It accepts the following parameter(s):
$smtpDebug(bool) —
It does not return anything or a mixed result.
isSmtpDebugEnabled()
Returns whether SMTP debugging is enabled or not
Signature
- It returns a
boolvalue.
getMailHost()
Returns the hostname mails will be sent from
Signature
- It returns a
stringvalue.
sanitiseString()
Replaces characters known to appear incorrectly in some email clients
Signature
It accepts the following parameter(s):
$string
It returns a
mixedvalue.