HEX
Server: nginx/1.18.0
System: Linux iZj6c1ieg2jrpk1z5tzi19Z 6.3.9-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 21 22:18:40 EDT 2023 x86_64
User: www (1001)
PHP: 8.2.4
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.cytocare.cn/wp-content/plugins/mailpoet/lib/Mailer/Methods/SMTP.php
<?php declare(strict_types = 1);

namespace MailPoet\Mailer\Methods;

if (!defined('ABSPATH')) exit;


use MailPoet\Mailer\Methods\ErrorMappers\SMTPMapper;
use MailPoet\RuntimeException;
use MailPoet\Util\Url;
use MailPoet\WP\Functions as WPFunctions;
use PHPMailer\PHPMailer\PHPMailer;

class SMTP extends PHPMailerMethod {
  const SMTP_CONNECTION_TIMEOUT = 15; // seconds

  /** @var string */
  public $host;
  /** @var int */
  public $port;
  /** @var int */
  public $authentication;
  /** @var string  */
  public $login;
  /** @var string */
  public $password;
  /** @var string */
  public $encryption;
  /** @var PHPMailer */
  public $mailer;
  /** @var WPFunctions */
  protected $wp;

  public function __construct(
    $host,
    $port,
    $authentication,
    $encryption,
    $sender,
    $replyTo,
    $returnPath,
    SMTPMapper $errorMapper,
    Url $urlUtils,
    $login = null,
    $password = null
  ) {
    $this->wp = new WPFunctions;
    $this->host = $host;
    $this->port = $port;
    $this->authentication = $authentication;
    $this->login = $login;
    $this->password = $password;
    $this->encryption = $encryption;
    parent::__construct($sender, $replyTo, $returnPath, $errorMapper, $urlUtils);
  }

  public function buildMailer(): PHPMailer {
    $mailer = new PHPMailer(true);
    $mailer->isSMTP();
    /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
    $mailer->Host = $this->wp->applyFilters('mailpoet_mailer_smtp_host', $this->host); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
    /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
    $mailer->Port = $this->wp->applyFilters('mailpoet_mailer_smtp_port', $this->port); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
    /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
    $mailer->SMTPSecure = $this->wp->applyFilters('mailpoet_mailer_smtp_encryption', $this->encryption);
    /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
    $mailer->SMTPOptions = $this->wp->applyFilters('mailpoet_mailer_smtp_options', []);
    /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
    $mailer->Timeout = $this->wp->applyFilters('mailpoet_mailer_smtp_connection_timeout', self::SMTP_CONNECTION_TIMEOUT); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps

    if ($this->authentication === 1) {
      $mailer->SMTPAuth = true; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
      $mailer->Username = $this->login; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
      $mailer->Password = $this->password; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
    }

    // values from filters can overwrite username and password
    $filterUsername = $this->wp->applyFilters('mailpoet_mailer_smtp_username', null);
    $filterPassword = $this->wp->applyFilters('mailpoet_mailer_smtp_password', null);
    if ($filterUsername && $filterPassword) {
      $mailer->SMTPAuth = true; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
      /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
      $mailer->Username = $filterUsername; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
      /** @phpstan-ignore-next-line - we cannot annotate the return type from a filter */
      $mailer->Password = $filterPassword; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
    }

    $mailer = $this->wp->applyFilters('mailpoet_mailer_smtp_instance', $mailer);
    if (!$mailer instanceof PHPMailer) {
      throw new RuntimeException(__('Filter "mailpoet_mailer_smtp_instance" must return an instance of PHPMailer.', 'mailpoet'));
    }
    return $mailer;
  }
}