Actions

API15

JUtility/sendMail

From Joomla! Documentation

< API15:JUtility
Revision as of 12:58, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Mail function (uses phpMailer)

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null)
Parameter Name Default Value Description
$from $from From e-mail address
$fromname $fromname From name
$recipient $recipient Recipient e-mail address(es)
$subject $subject E-mail subject
$body $body Message body
$mode 0 $mode false = plain text, true = HTML
$cc null $cc CC e-mail address(es)
$bcc null $bcc BCC e-mail address(es)
$attachment null $attachment Attachment file name(s)
$replyto null $replyto Reply to email address(es)
$replytoname null $replytoname Reply to name(s)

Returns

boolean True on success

Defined in

libraries/joomla/utilities/utility.php

Importing

jimport( 'joomla.utilities.utility' );

Source Body

function sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null )
{
        // Get a JMail instance
        $mail =& JFactory::getMailer();
 
        $mail->setSender(array($from, $fromname));
        $mail->setSubject($subject);
        $mail->setBody($body);
 
        // Are we sending the email as HTML?
        if ( $mode ) {
                $mail->IsHTML(true);
        }
 
        $mail->addRecipient($recipient);
        $mail->addCC($cc);
        $mail->addBCC($bcc);
        $mail->addAttachment($attachment);
 
        // Take care of reply email addresses
        if( is_array( $replyto ) ) {
                $numReplyTo = count($replyto);
                for ( $i=0; $i < $numReplyTo; $i++){
                        $mail->addReplyTo( array($replyto[$i], $replytoname[$i]) );
                }
        } elseif( isset( $replyto ) ) {
                $mail->addReplyTo( array( $replyto, $replytoname ) );
        }
 
        return  $mail->Send();
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />