function PHPMailer::SmtpSend in SMTP Authentication Support 5
Same name and namespace in other branches
- 7.2 smtp.phpmailer.inc \PHPMailer::SmtpSend()
- 7 smtp.phpmailer.inc \PHPMailer::SmtpSend()
Sends mail via SMTP using PhpSMTP (Author: Chris Ryan). Returns bool. Returns false if there is a bad MAIL FROM, RCPT, or DATA input. @access private
Return value
bool
1 call to PHPMailer::SmtpSend()
- PHPMailer::Send in ./
smtp.module - Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
File
- ./
smtp.module, line 908 - Enables drupal to send email directly to an SMTP server using authentication. Uses the PHPMailer class by Brent R. Matzelle.
Class
- PHPMailer
- PHPMailer - PHP email transport class @package PHPMailer @author Brent R. Matzelle @copyright 2001 - 2003 Brent R. Matzelle
Code
function SmtpSend($header, $body) {
//include_once($this->PluginDir . "class.smtp.php");
$error = "";
$bad_rcpt = array();
if (!$this
->SmtpConnect()) {
return false;
}
$smtp_from = $this->Sender == "" ? $this->From : $this->Sender;
if (!$this->smtp
->Mail($smtp_from)) {
$error = $this
->Lang("from_failed") . $smtp_from;
$this
->SetError($error);
$this->smtp
->Reset();
return false;
}
// Attempt to send attach all recipients
for ($i = 0; $i < count($this->to); $i++) {
if (!$this->smtp
->Recipient($this->to[$i][0])) {
$bad_rcpt[] = $this->to[$i][0];
}
}
for ($i = 0; $i < count($this->cc); $i++) {
if (!$this->smtp
->Recipient($this->cc[$i][0])) {
$bad_rcpt[] = $this->cc[$i][0];
}
}
for ($i = 0; $i < count($this->bcc); $i++) {
if (!$this->smtp
->Recipient($this->bcc[$i][0])) {
$bad_rcpt[] = $this->bcc[$i][0];
}
}
if (count($bad_rcpt) > 0) {
// Create error message
for ($i = 0; $i < count($bad_rcpt); $i++) {
if ($i != 0) {
$error .= ", ";
}
$error .= $bad_rcpt[$i];
}
$error = $this
->Lang("recipients_failed") . $error;
$this
->SetError($error);
$this->smtp
->Reset();
return false;
}
if (!$this->smtp
->Data($header . $body)) {
$this
->SetError($this
->Lang("data_not_accepted"));
$this->smtp
->Reset();
return false;
}
if ($this->SMTPKeepAlive == true) {
$this->smtp
->Reset();
}
else {
$this
->SmtpClose();
}
return true;
}