You are here

public function DrupalPHPMailer::__construct in PHPMailer 6.3

Same name and namespace in other branches
  1. 5.2 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 52
Implements the base PHPMailer for Drupal class.

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).
  if (method_exists(get_parent_class($this), '__construct')) {
    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->drupalDebug = variable_get('smtp_debug', 0);
  if ($this->drupalDebug > $this->SMTPDebug) {
    $this->SMTPDebug = $this->drupalDebug;
  }

  // Adjust path to SMTP class.
  $this->PluginDir = './' . phpmailer_get_path() . '/';
}