JMail

Extends \PHPMailer

Email Class. Provides a common interface to send email from the Joomla! Platform

package

Joomla.Platform

subpackage

Mail

since

11.1

Methods

__construct

Constructor

__construct() 

addAttachment

Add file attachments to the email

addAttachment(mixed $attachment, mixed $name = '', mixed $encoding = 'base64', mixed $type = 'application/octet-stream') : \JMail
since

11.1

Arguments

$attachment

mixedEither a string or array of strings [filenames]

$name

mixedEither a string or array of strings [names]

$encoding

mixedThe encoding of the attachment

$type

mixedThe mime type

Response

\JMailReturns this object for chaining.

addBCC

Add blind carbon copy recipients to the email

addBCC(mixed $bcc, mixed $name = '') : \JMail
since

11.1

Arguments

$bcc

mixedEither a string or array of strings [email address(es)]

$name

mixedEither a string or array of strings [name(s)]

Response

\JMailReturns this object for chaining.

addCC

Add carbon copy recipients to the email

addCC(mixed $cc, mixed $name = '') : \JMail
since

11.1

Arguments

$cc

mixedEither a string or array of strings [email address(es)]

$name

mixedEither a string or array of strings [name(s)]

Response

\JMailReturns this object for chaining.

addRecipient

Add recipients to the email

addRecipient(mixed $recipient, mixed $name = '') : \JMail
since

11.1

Arguments

$recipient

mixedEither a string or array of strings [email address(es)]

$name

mixedEither a string or array of strings [name(s)]

Response

\JMailReturns this object for chaining.

addReplyTo

Add Reply to email address(es) to the email

addReplyTo(array $replyto, mixed $name = '') : \JMail
since

11.1

Arguments

$replyto

arrayEither an array or multi-array of form array([0] => email Address [1] => Name)

$name

mixedEither an array or single string

Response

\JMailReturns this object for chaining.

getInstance

Returns the global email object, only creating it if it doesn't already exist.

getInstance(string $id = 'Joomla') : \JMail
static

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

11.1

Arguments

$id

stringThe id string for the JMail instance [optional]

Response

\JMailThe global JMail object

Send

Send the mail

Send() : mixed
since

11.1

Response

mixedTrue if successful, a JError object otherwise

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

11.1

Arguments

$adminName

stringName of administrator

$adminEmail

stringEmail address of administrator

$email

string[NOT USED TODO: Deprecate?]

$type

stringType of item to approve

$title

stringTitle of item to approve

$author

stringAuthor of item to approve

$url

stringA URL to included in the mail

Response

booleanTrue 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

11.1

Arguments

$from

stringFrom email address

$fromName

stringFrom name

$recipient

mixedRecipient email address(es)

$subject

stringemail subject

$body

stringMessage body

$mode

booleanfalse = plain text, true = HTML

$cc

mixedCC email address(es)

$bcc

mixedBCC email address(es)

$attachment

mixedAttachment file name(s)

$replyTo

mixedReply to email address(es)

$replyToName

mixedReply to name(s)

Response

booleanTrue on success

setBody

Set the email body

setBody(string $content) : \JMail
since

11.1

Arguments

$content

stringBody of the email

Response

\JMailReturns this object for chaining.

setSender

Set the email sender

setSender(array $from) : \JMail
since

11.1

Arguments

$from

arrayemail address and Name of sender array([0] => email Address [1] => Name)

Response

\JMailReturns this object for chaining.

setSubject

Set the email subject

setSubject(string $subject) : \JMail
since

11.1

Arguments

$subject

stringSubject of the email

Response

\JMailReturns this object for chaining.

useSendmail

Use sendmail for sending the email

useSendmail(string $sendmail = null) : boolean
since

11.1

Arguments

$sendmail

stringPath to sendmail [optional]

Response

booleanTrue 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

11.1

Arguments

$auth

stringSMTP Authentication [optional]

$host

stringSMTP Host [optional]

$user

stringSMTP Username [optional]

$pass

stringSMTP Password [optional]

$secure

stringUse secure methods

$port

integerThe SMTP port

Response

booleanTrue on success

Properties

instances

JMail instances container.

static
since

11.3

Type(s)

array

CharSet

Charset of the message.

since

11.1

Type(s)

string