JMail/sendMail
From Joomla! Documentation
< API16:JMail
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Function to send an e-mail
Syntax[edit]
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[edit]
boolean True on success
Defined in[edit]
libraries/joomla/mail/mail.php
Importing[edit]
jimport( 'joomla.mail.mail' );
Source Body[edit]
public function sendMail($from, $fromName, $recipient, $subject, $body, $mode=0,
$cc=null, $bcc=null, $attachment=null, $replyTo=null, $replyToName=null)
{
$this->setSender(array($from, $fromName));
$this->setSubject($subject);
$this->setBody($body);
// Are we sending the email as HTML?
if ($mode) {
$this->IsHTML(true);
}
$this->addRecipient($recipient);
$this->addCC($cc);
$this->addBCC($bcc);
$this->addAttachment($attachment);
// Take care of reply email addresses
if (is_array($replyTo)) {
$numReplyTo = count($replyTo);
for ($i=0; $i < $numReplyTo; $i++){
$this->addReplyTo(array($replyTo[$i], $replyToName[$i]));
}
} elseif (isset($replyTo)) {
$this->addReplyTo(array($replyTo, $replyToName));
}
return $this->Send();
}
Examples[edit]
Code Examples[edit]