Email Class. Provides a common interface to send email from the Joomla! Platform
since |
1.7.0 |
---|
Methods
__construct
Constructor
__construct(boolean $exceptions = true)
since |
1.7.0 |
---|
Arguments
- $exceptions
boolean
Flag if Exceptions should be thrown
add
Add recipients to the email.
add(mixed $recipient, mixed $name = '', string $method = 'addAddress') : \Joomla\CMS\Mail\Mail|boolean
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $recipient
mixed
Either a string or array of strings [email address(es)]- $name
mixed
Either a string or array of strings [name(s)]- $method
string
The parent method's name.
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining on success or boolean false on failure.
addAttachment
Add file attachment to the email
addAttachment(mixed $path, mixed $name = '', mixed $encoding = 'base64', mixed $type = 'application/octet-stream', string $disposition = 'attachment') : \Joomla\CMS\Mail\Mail|boolean
since |
3.0.1 |
---|---|
throws |
|
Arguments
- $path
mixed
Either a string or array of strings [filenames]- $name
mixed
Either a string or array of strings [names]. N.B. if this is an array it must contain the same number of elements as the array of paths supplied.- $encoding
mixed
The encoding of the attachment- $type
mixed
The mime type- $disposition
string
The disposition of the attachment
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining on success or boolean false on failure.
addBcc
Add blind carbon copy recipients to the email
addBcc(mixed $bcc, mixed $name = '') : \Joomla\CMS\Mail\Mail|boolean
since |
1.7.0 |
---|
Arguments
- $bcc
mixed
Either a string or array of strings [email address(es)]- $name
mixed
Either a string or array of strings [name(s)]
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining on success or boolean false on failure.
addCc
Add carbon copy recipients to the email
addCc(mixed $cc, mixed $name = '') : \Joomla\CMS\Mail\Mail|boolean
since |
1.7.0 |
---|
Arguments
- $cc
mixed
Either a string or array of strings [email address(es)]- $name
mixed
Either a string or array of strings [name(s)]
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining on success or boolean false on failure.
addRecipient
Add recipients to the email
addRecipient(mixed $recipient, mixed $name = '') : \Joomla\CMS\Mail\Mail|boolean
since |
1.7.0 |
---|
Arguments
- $recipient
mixed
Either a string or array of strings [email address(es)]- $name
mixed
Either a string or array of strings [name(s)]
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining.
addReplyTo
Add Reply to email address(es) to the email
addReplyTo(mixed $replyto, mixed $name = '') : \Joomla\CMS\Mail\Mail|boolean
since |
1.7.0 |
---|
Arguments
- $replyto
mixed
Either a string or array of strings [email address(es)]- $name
mixed
Either a string or array of strings [name(s)]
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining on success or boolean false on failure.
clearAttachments
Unset all file attachments from the email
clearAttachments() : \Joomla\CMS\Mail\Mail
getInstance
Returns the global email object, only creating it if it doesn't already exist.
getInstance(string $id = 'Joomla', boolean $exceptions = true) : \Joomla\CMS\Mail\Mail
NOTE: If you need an instance to use that does not have the global configuration values, use an id string that is not 'Joomla'.
since |
1.7.0 |
---|
Arguments
- $id
string
The id string for the Mail instance [optional]- $exceptions
boolean
Flag if Exceptions should be thrown [optional]
Response
\Joomla\CMS\Mail\Mail
The global Mail object
isHtml
Sets message type to HTML
isHtml(boolean $ishtml = true) : \Joomla\CMS\Mail\Mail
since |
3.1.4 |
---|
Arguments
- $ishtml
boolean
Boolean true or false.
Response
\Joomla\CMS\Mail\Mail
Returns this object for chaining.
isSendmail
Send messages using $Sendmail.
isSendmail() : void
This overrides the parent class to remove the restriction on the executable's name containing the word "sendmail"
since |
1.7.0 |
---|
removeAttachment
Unset file attachments specified by array index.
removeAttachment(integer $index) : \Joomla\CMS\Mail\Mail
since |
3.0.1 |
---|
Arguments
- $index
integer
The numerical index of the attachment to remove
Response
\Joomla\CMS\Mail\Mail
Returns this object for chaining.
Send
Send the mail
Send() : boolean|\JException
since |
1.7.0 |
---|---|
throws |
|
Response
boolean|\JException
Boolean true if successful, boolean false if the mailonline
configuration is set to 0,
or a JException object if the mail function does not exist or sending the message fails.
sendAdminMail
Sends mail to administrator for approval of a user submission
sendAdminMail(string $adminName, string $adminEmail, string $email, string $type, string $title, string $author, string $url = null) : boolean
since |
1.7.0 |
---|---|
deprecated |
4.0 Without replacement please implement it in your own code |
Arguments
- $adminName
string
Name of administrator- $adminEmail
string
Email address of administratorstring
[NOT USED TODO: Deprecate?]- $type
string
Type of item to approve- $title
string
Title of item to approve- $author
string
Author of item to approve- $url
string
A URL to included in the mail
Response
boolean
True on success
sendMail
Function to send an email
sendMail(string $from, string $fromName, mixed $recipient, string $subject, string $body, boolean $mode = false, mixed $cc = null, mixed $bcc = null, mixed $attachment = null, mixed $replyTo = null, mixed $replyToName = null) : boolean
since |
1.7.0 |
---|
Arguments
- $from
string
From email address- $fromName
string
From name- $recipient
mixed
Recipient email address(es)- $subject
string
email subject- $body
string
Message body- $mode
boolean
false = plain text, true = HTML- $cc
mixed
CC email address(es)- $bcc
mixed
BCC email address(es)- $attachment
mixed
Attachment file name(s)- $replyTo
mixed
Reply to email address(es)- $replyToName
mixed
Reply to name(s)
Response
boolean
True on success
setBody
Set the email body
setBody(string $content) : \Joomla\CMS\Mail\Mail
since |
1.7.0 |
---|
Arguments
- $content
string
Body of the email
Response
\Joomla\CMS\Mail\Mail
Returns this object for chaining.
setFrom
Set the From and FromName properties.
setFrom(string $address, string $name = '', boolean $auto = true) : boolean
since |
1.7.0 |
---|
Arguments
- $address
string
The sender email address- $name
string
The sender name- $auto
boolean
Whether to also set the Sender address, defaults to true
Response
boolean
setSender
Set the email sender
setSender(mixed $from) : \Joomla\CMS\Mail\Mail|boolean
since |
1.7.0 |
---|---|
throws |
|
Arguments
- $from
mixed
email address and Name of senderarray([0] => email Address, [1] => Name)
or as a string
Response
\Joomla\CMS\Mail\Mail|boolean
Returns this object for chaining on success or boolean false on failure.
setSubject
Set the email subject
setSubject(string $subject) : \Joomla\CMS\Mail\Mail
since |
1.7.0 |
---|
Arguments
- $subject
string
Subject of the email
Response
\Joomla\CMS\Mail\Mail
Returns this object for chaining.
useSendmail
Use sendmail for sending the email
useSendmail(string $sendmail = null) : boolean
since |
1.7.0 |
---|
Arguments
- $sendmail
string
Path to sendmail [optional]
Response
boolean
True on success
useSmtp
Use SMTP for sending the email
useSmtp(string $auth = null, string $host = null, string $user = null, string $pass = null, string $secure = null, integer $port = 25) : boolean
since |
1.7.0 |
---|
Arguments
- $auth
string
SMTP Authentication [optional]- $host
string
SMTP Host [optional]- $user
string
SMTP Username [optional]- $pass
string
SMTP Password [optional]- $secure
string
Use secure methods- $port
integer
The SMTP port
Response
boolean
True on success
Properties
CharSet
Charset of the message.
since |
1.7.0 |
---|
Type(s)
string