Source code for file /joomla/mail/mail.php
Documentation is available at mail.php
* @version $Id: mail.php 12308 2009-06-23 04:05:28Z ian $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* E-Mail Class. Provides a common interface to send e-mail from the Joomla! Framework
* @package Joomla.Framework
// phpmailer has an issue using the relative path for it's language files
* Returns a reference to a global e-mail object, only creating it
* if it doesn't already exist.
* This method must be invoked as:
* <pre> $mail =& JMail::getInstance();</pre>
* NOTE: If you need an instance to use that does not have the global configuration
* values, use an id string that is not 'Joomla'.
* @param string $id The id string for the JMail instance [optional]
* @return object The global JMail object
if (!isset
($instances)) {
if (empty ($instances[$id])) {
$instances[$id] =
new JMail();
* @return mixed True if successful, a JError object otherwise
@ $result =
parent::Send();
// TODO: Set an appropriate error number
* @param array $from E-Mail address and Name of sender
* array( [0] => E-Mail Address [1] => Name )
// If $from is an array we assume it has an address and a name
// If it is a string we assume it is just the address
// If it is neither, we throw a warning
JError::raiseWarning( 0, "JMail:: Invalid E-Mail Sender: $from", "JMail::setSender($from)");
* @param string $subject Subject of the e-mail
* @param string $content Body of the e-mail
* Add recipients to the email
* @param mixed $recipient Either a string or array of strings [e-mail address(es)]
// If the recipient is an aray, add each recipient... otherwise just add the one
foreach ($recipient as $to) {
* Add carbon copy recipients to the email
* @param mixed $cc Either a string or array of strings [e-mail address(es)]
//If the carbon copy recipient is an aray, add each recipient... otherwise just add the one
* Add blind carbon copy recipients to the email
* @param mixed $cc Either a string or array of strings [e-mail address(es)]
// If the blind carbon copy recipient is an aray, add each recipient... otherwise just add the one
* Add file attachments to the email
* @param mixed $attachment Either a string or array of strings [filenames]
// If the file attachments is an aray, add each file... otherwise just add the one
foreach ($attachment as $file) {
* Add Reply to e-mail address(es) to the e-mail
* @param array $reply Either an array or multi-array of form
* array( [0] => E-Mail Address [1] => Name )
// Take care of reply email addresses
foreach ($replyto as $to) {
* Use sendmail for sending the e-mail
* @param string $sendmail Path to sendmail [optional]
* @return boolean True on success
* Use SMTP for sending the e-mail
* @param string $auth SMTP Authentication [optional]
* @param string $host SMTP Host [optional]
* @param string $user SMTP Username [optional]
* @param string $pass SMTP Password [optional]
* @param string $secure SMTP Secure ssl,tls [optinal]
* @param string $port SMTP Port [optional]
* @return boolean True on success
function useSMTP($auth =
null, $host =
null, $user =
null, $pass =
null,$secure =
null, $port =
25)
if ($secure ==
'ssl' ||
$secure ==
'tls') {