API16:JMail/sendMail
From Joomla! Documentation
Description
Function to send an e-mail
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/mail/mail.php
Importing
jimport( 'joomla.mail.mail' );
Source Body
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
Code Examples