Back to Joomla project (class list)

Class Mail - list of methods

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

Direct known subclasses

Package: Joomla\CMS\Mail
Copyright: (C) 2006 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Mail/Mail.php
Project: Joomla

Method Summary

public
(mixed $exceptions = true)

Constructor
Parameters
  • bool $exceptions Flag if Exceptions should be thrown
Since
  • 1.7.0
Show source code of this method: __construct Source Code

public static \Joomla\CMS\Mail\Mail
(mixed $id = 'Joomla', mixed $exceptions = true)

Returns the global email object, only creating it if it doesn't already exist.
Parameters
  • string $id The id string for the Mail instance [optional]
  • bool $exceptions Flag if Exceptions should be thrown [optional]
Returns
  • \Joomla\CMS\Mail\Mail The global Mail object
Since
  • 1.7.0
Show source code of this method: getInstance Source Code

public bool
()

Send the mail
Returns
  • bool Boolean true if successful, false if exception throwing is disabled.
Since
  • 1.7.0
-
  • \Joomla\CMS\Mail\Exception\MailDisabledException if the mail function is disabled
  • \PHPMailer\PHPMailer\Exception if sending failed
Show source code of this method: Send Source Code

public \Joomla\CMS\Mail\Mail|bool
(mixed $from)

Set the email sender
Parameters
  • mixed $from email address and Name of sender <code>array([0] => email Address, [1] => Name)</code> or as a string
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or boolean false on failure.
Since
  • 1.7.0
-
  • \UnexpectedValueException if the sender is not a valid address
  • \PHPMailer\PHPMailer\Exception if setting the sender failed and exception throwing is enabled
Show source code of this method: setSender Source Code

public \Joomla\CMS\Mail\Mail
(mixed $subject)

Set the email subject
Parameters
  • string $subject Subject of the email
Returns
  • \Joomla\CMS\Mail\Mail Returns this object for chaining.
Since
  • 1.7.0
Show source code of this method: setSubject Source Code

public \Joomla\CMS\Mail\Mail
(mixed $content)

Set the email body
Parameters
  • string $content Body of the email
Returns
  • \Joomla\CMS\Mail\Mail Returns this object for chaining.
Since
  • 1.7.0
Show source code of this method: setBody Source Code

protected \Joomla\CMS\Mail\Mail|bool
(mixed $recipient, mixed $name = '', mixed $method = 'addAddress')

Add recipients to the email.
Parameters
  • mixed $recipient Either a string or array of strings [email address(es)]
  • mixed $name Either a string or array of strings [name(s)]
  • string $method The parent method's name.
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or boolean false on failure.
Since
  • 1.7.0
-
  • \InvalidArgumentException if the argument array counts do not match
  • \PHPMailer\PHPMailer\Exception if setting the address failed and exception throwing is enabled
Show source code of this method: add Source Code

public \Joomla\CMS\Mail\Mail|bool
(mixed $recipient, mixed $name = '')

Add recipients to the email
Parameters
  • mixed $recipient Either a string or array of strings [email address(es)]
  • mixed $name Either a string or array of strings [name(s)]
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or false on failure when exception throwing is disabled.
Since
  • 1.7.0
-
  • \PHPMailer\PHPMailer\Exception if exception throwing is enabled
Show source code of this method: addRecipient Source Code

public \Joomla\CMS\Mail\Mail|bool
(mixed $cc, mixed $name = '')

Add carbon copy recipients to the email
Parameters
  • mixed $cc Either a string or array of strings [email address(es)]
  • mixed $name Either a string or array of strings [name(s)]
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or boolean false on failure when exception throwing is enabled.
Since
  • 1.7.0
-
  • \PHPMailer\PHPMailer\Exception if exception throwing is enabled
Show source code of this method: addCc Source Code

public \Joomla\CMS\Mail\Mail|bool
(mixed $bcc, mixed $name = '')

Add blind carbon copy recipients to the email
Parameters
  • mixed $bcc Either a string or array of strings [email address(es)]
  • mixed $name Either a string or array of strings [name(s)]
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or boolean false on failure when exception throwing is disabled.
Since
  • 1.7.0
-
  • \PHPMailer\PHPMailer\Exception if exception throwing is enabled
Show source code of this method: addBcc Source Code

public \Joomla\CMS\Mail\Mail|bool
(mixed $path, mixed $name = '', mixed $encoding = 'base64', mixed $type = 'application/octet-stream', mixed $disposition = 'attachment')

Add file attachment to the email
Parameters
  • mixed $path Either a string or array of strings [filenames]
  • mixed $name 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.
  • mixed $encoding The encoding of the attachment
  • mixed $type The mime type
  • string $disposition The disposition of the attachment
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or boolean false on failure when exception throwing is disabled.
Since
  • 3.0.1
-
  • \InvalidArgumentException if the argument array counts do not match
  • \PHPMailer\PHPMailer\Exception if setting the attachment failed and exception throwing is enabled
Show source code of this method: addAttachment Source Code

public \Joomla\CMS\Mail\Mail
()

Unset all file attachments from the email
Returns
  • \Joomla\CMS\Mail\Mail Returns this object for chaining.
Since
  • 3.0.1
Show source code of this method: clearAttachments Source Code

public \Joomla\CMS\Mail\Mail
(mixed $index = 0)

Unset file attachments specified by array index.
Parameters
  • int $index The numerical index of the attachment to remove
Returns
  • \Joomla\CMS\Mail\Mail Returns this object for chaining.
Since
  • 3.0.1
Show source code of this method: removeAttachment Source Code

public \Joomla\CMS\Mail\Mail|bool
(mixed $replyto, mixed $name = '')

Add Reply to email address(es) to the email
Parameters
  • mixed $replyto Either a string or array of strings [email address(es)]
  • mixed $name Either a string or array of strings [name(s)]
Returns
  • \Joomla\CMS\Mail\Mail|bool Returns this object for chaining on success or boolean false on failure when exception throwing is disabled.
Since
  • 1.7.0
-
  • \PHPMailer\PHPMailer\Exception if exception throwing is enabled
Show source code of this method: addReplyTo Source Code

public \Joomla\CMS\Mail\Mail
(mixed $ishtml = true)

Sets message type to HTML
Parameters
  • bool $ishtml Boolean true or false.
Returns
  • \Joomla\CMS\Mail\Mail Returns this object for chaining.
Since
  • 3.1.4
Show source code of this method: isHtml Source Code

public void
()

Send messages using $Sendmail.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: isSendmail Source Code

public bool
(mixed $sendmail = null)

Use sendmail for sending the email
Parameters
  • string $sendmail Path to sendmail [optional]
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: useSendmail Source Code

public bool
(mixed $auth = null, mixed $host = null, mixed $user = null, mixed $pass = null, mixed $secure = null, mixed $port = 25)

Use SMTP for sending the email
Parameters
  • string $auth SMTP Authentication [optional]
  • string $host SMTP Host [optional]
  • string $user SMTP Username [optional]
  • string $pass SMTP Password [optional]
  • string $secure Use secure methods
  • int $port The SMTP port
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: useSmtp Source Code

public bool
(mixed $from, mixed $fromName, mixed $recipient, mixed $subject, mixed $body, mixed $mode = false, mixed $cc = null, mixed $bcc = null, mixed $attachment = null, mixed $replyTo = null, mixed $replyToName = null)

Function to send an email
Parameters
  • string $from From email address
  • string $fromName From name
  • mixed $recipient Recipient email address(es)
  • string $subject email subject
  • string $body Message body
  • bool $mode false = plain text, true = HTML
  • mixed $cc CC email address(es)
  • mixed $bcc BCC email address(es)
  • mixed $attachment Attachment file name(s)
  • mixed $replyTo Reply to email address(es)
  • mixed $replyToName Reply to name(s)
Returns
  • bool True on success, false on failure when exception throwing is disabled.
Since
  • 1.7.0
-
  • \Joomla\CMS\Mail\Exception\MailDisabledException if the mail function is disabled
  • \PHPMailer\PHPMailer\Exception if exception throwing is enabled
Show source code of this method: sendMail Source Code

Properties Summary

protected static \Joomla\CMS\Mail\Mail[]
$instances
Mail instances container.
Since
  • 1.7.3
public string
$CharSet
Charset of the message.
Since
  • 1.7.0

Tags Summary

Since
1.7.0