You are here

public function DrupalPHPMailer::__construct in PHPMailer 7.4

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

Constructor.

File

includes/phpmailer.class.inc, line 58
Implements the base PHPMailer for Drupal class.

Class

DrupalPHPMailer
Class for implementing the PHPMailer library in Drupal.

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', '');
  $this->SMTPOptions['ssl']['verify_peer'] = variable_get('ssl_verify_peer', 1);
  $this->SMTPOptions['ssl']['verify_peer_name'] = variable_get('ssl_verify_peer_name', 1);
  $this->SMTPOptions['ssl']['allow_self_signed'] = variable_get('ssl_allow_self_signed', 0);

  // 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 != '');
  $auth_type = variable_get('smtp_auth_type', '');
  if ($this->SMTPAuth && $auth_type) {
    $this->AuthType = $auth_type;
  }
  $this->SMTPKeepAlive = variable_get('smtp_keepalive', 0);
  $this->drupalDebug = variable_get('smtp_debug', 0);
  if ($this->drupalDebug > $this->SMTPDebug && user_access('administer phpmailer settings')) {
    $this->SMTPDebug = $this->drupalDebug;
  }

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