You are here

function PHPMailer::Send in SMTP Authentication Support 5

Same name and namespace in other branches
  1. 7.2 smtp.phpmailer.inc \PHPMailer::Send()
  2. 7 smtp.phpmailer.inc \PHPMailer::Send()

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.

Return value

bool

File

./smtp.module, line 792
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 Send() {
  $header = "";
  $body = "";
  $result = true;
  if (count($this->to) + count($this->cc) + count($this->bcc) < 1) {
    $this
      ->SetError($this
      ->Lang("provide_address"));
    return false;
  }

  // Set whether the message is multipart/alternative
  if (!empty($this->AltBody)) {
    $this->ContentType = "multipart/alternative";
  }
  $this->error_count = 0;

  // reset errors
  $this
    ->SetMessageType();
  $header .= $this
    ->CreateHeader();
  $body = $this
    ->CreateBody();
  if ($body == "") {
    return false;
  }

  // Choose the mailer
  switch ($this->Mailer) {
    case "sendmail":
      $result = $this
        ->SendmailSend($header, $body);
      break;
    case "mail":
      $result = $this
        ->MailSend($header, $body);
      break;
    case "smtp":
      $result = $this
        ->SmtpSend($header, $body);
      break;
    default:
      $this
        ->SetError($this->Mailer . $this
        ->Lang("mailer_not_supported"));
      $result = false;
      break;
  }
  return $result;
}