You are here

public function DrupalPHPMailer::__construct in PHPMailer 5.2

Same name and namespace in other branches
  1. 6.3 includes/phpmailer.class.inc \DrupalPHPMailer::__construct()
  2. 6.2 includes/phpmailer.class.inc \DrupalPHPMailer::__construct()
  3. 7.4 includes/phpmailer.class.inc \DrupalPHPMailer::__construct()
  4. 7.3 includes/phpmailer.class.inc \DrupalPHPMailer::__construct()

Constructor.

File

includes/phpmailer.class.inc, line 23

Class

DrupalPHPMailer
Base PHPMailer for Drupal implementation with support for SMTP keep-alive and setting a custom Return-Path.

Code

public function __construct() {

  // Throw exceptions instead of dying (since 5.0.0).
  parent::__construct(TRUE);
  $this
    ->IsSMTP();
  $this
    ->Reset();
  $this->Host = variable_get('smtp_host', '');
  if ($backup = variable_get('smtp_hostbackup', '')) {
    $this->Host .= ';' . $backup;
  }
  $this->Port = variable_get('smtp_port', '25');
  $this->SMTPSecure = variable_get('smtp_protocol', '');

  // Use SMTP authentication if both username and password are given.
  $this->Username = variable_get('smtp_username', '');
  $this->Password = variable_get('smtp_password', '');
  $this->SMTPAuth = (bool) ($this->Username != '' && $this->Password != '');
  $this->SMTPKeepAlive = variable_get('smtp_keepalive', 0);
  $this->SMTPDebug = variable_get('smtp_debug', 0);

  // Adjust path to SMTP class.
  $this->PluginDir = drupal_get_path('module', 'phpmailer') . '/phpmailer/';
}