You are here

function PHPMailer::MailSend in SMTP Authentication Support 5

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

Sends mail using the PHP mail() function. @access private

Return value

bool

1 call to PHPMailer::MailSend()
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 870
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 MailSend($header, $body) {
  $to = "";
  for ($i = 0; $i < count($this->to); $i++) {
    if ($i != 0) {
      $to .= ", ";
    }
    $to .= $this->to[$i][0];
  }
  if ($this->Sender != "" && strlen(ini_get("safe_mode")) < 1) {
    $old_from = ini_get("sendmail_from");
    ini_set("sendmail_from", $this->Sender);
    $params = sprintf("-oi -f %s", $this->Sender);
    $rt = @mail($to, $this
      ->EncodeHeader($this->Subject), $body, $header, $params);
  }
  else {
    $rt = @mail($to, $this
      ->EncodeHeader($this->Subject), $body, $header);
  }
  if (isset($old_from)) {
    ini_set("sendmail_from", $old_from);
  }
  if (!$rt) {
    $this
      ->SetError($this
      ->Lang("instantiate"));
    return false;
  }
  return true;
}