: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Used if your key is encrypted.
public $DKIM_passphrase = '';
* DKIM signing domain name.
public $DKIM_domain = '';
* DKIM Copy header field values for diagnostic use.
public $DKIM_copyHeaderFields = true;
* DKIM Extra signing headers.
* @example ['List-Unsubscribe', 'List-Help']
public $DKIM_extraHeaders = [];
* DKIM private key file path.
public $DKIM_private = '';
* DKIM private key string.
* If set, takes precedence over `$DKIM_private`.
public $DKIM_private_string = '';
* Callback Action function name.
* The function that handles the result of the send email action.
* It is called out by send() for each email sent.
* Value can be any php callable: http://www.php.net/is_callable
* bool $result result of the send action
* array $to email addresses of the recipients
* array $cc cc email addresses
* array $bcc bcc email addresses
* string $subject the subject
* string $body the email body
* string $from email address of sender
* string $extra extra information of possible use
* "smtp_transaction_id' => last smtp transaction id
public $action_function = '';
* What to put in the X-Mailer header.
* Options: An empty string for PHPMailer default, whitespace/null for none, or a string to use.
* Which validator to use by default when validating email addresses.
* May be a callable to inject your own validator, but there are several built-in validators.
* The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option.
* @see PHPMailer::validateAddress()
public static $validator = 'php';
* An instance of the SMTP sender class.
* The array of 'to' names and addresses.
* The array of 'cc' names and addresses.
* The array of 'bcc' names and addresses.
* The array of reply-to names and addresses.
* An array of all kinds of addresses.
* Includes all of $to, $cc, $bcc.
protected $all_recipients = [];
* An array of names and addresses queued for validation.
* In send(), valid and non duplicate entries are moved to $all_recipients
* and one of $to, $cc, or $bcc.
* This array is used only for addresses with IDN.
* @see PHPMailer::$all_recipients
protected $RecipientsQueue = [];
* An array of reply-to names and addresses queued for validation.
* In send(), valid and non duplicate entries are moved to $ReplyTo.
* This array is used only for addresses with IDN.
* @see PHPMailer::$ReplyTo
protected $ReplyToQueue = [];
* The array of attachments.
protected $attachment = [];
* The array of custom headers.
protected $CustomHeader = [];
* The most recent Message-ID (including angular brackets).
protected $lastMessageID = '';
* The message's MIME type.
protected $message_type = '';
* The array of MIME boundary strings.
protected $boundary = [];
* The array of available text strings for the current language.
protected $language = [];
* The number of errors encountered.
protected $error_count = 0;
* The S/MIME certificate file path.
protected $sign_cert_file = '';
* The S/MIME key file path.
protected $sign_key_file = '';
* The optional S/MIME extra certificates ("CA Chain") file path.
protected $sign_extracerts_file = '';
* The S/MIME password for the key.
* Used only if the key is encrypted.
protected $sign_key_pass = '';
* Whether to throw exceptions for errors.
protected $exceptions = false;
* Unique ID used for message ID and boundaries.
protected $uniqueid = '';
* The PHPMailer Version number.
* Error severity: message only, continue processing.
* Error severity: message, likely ok to continue processing.
* Error severity: message, plus full stop, critical error reached.
* The SMTP standard CRLF line break.
* If you want to change line break format, change static::$LE, not this.
* "Folding White Space" a white space string used for line folding.
* SMTP RFC standard line ending; Carriage Return, Line Feed.
protected static $LE = self::CRLF;
* The maximum line length supported by mail().
* Background: mail() will sometimes corrupt messages
* with headers longer than 65 chars, see #818.
const MAIL_MAX_LINE_LENGTH = 63;
* The maximum line length allowed by RFC 2822 section 2.1.1.
const MAX_LINE_LENGTH = 998;
* The lower maximum line length allowed by RFC 2822 section 2.1.1.
* This length does NOT include the line break
* 76 means that lines will be 77 or 78 chars depending on whether
* the line break format is LF or CRLF; both are valid.
const STD_LINE_LENGTH = 76;
* @param bool $exceptions Should we throw external exceptions?
public function __construct($exceptions = null)
if (null !== $exceptions) {
$this->exceptions = (bool) $exceptions;
//Pick an appropriate debug output format automatically
$this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html');
public function __destruct()
//Close any open SMTP connection nicely
* Call mail() in a safe_mode-aware fashion.
* Also, unless sendmail_path points to sendmail (or something that
* claims to be sendmail), don't pass params (not a perfect fix,
* @param string $subject Subject
* @param string $body Message Body
* @param string $header Additional Header(s)
* @param string|null $params Params
private function mailPassthru($to, $subject, $body, $header, $params)
//Check overloading of mail function to avoid double-encoding
if ((int)ini_get('mbstring.func_overload') & 1) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
$subject = $this->secureHeader($subject);
$subject = $this->encodeHeader($this->secureHeader($subject));
//Calling mail() with null params breaks
$this->edebug('Sending with mail()');
$this->edebug('Sendmail path: ' . ini_get('sendmail_path'));
$this->edebug("Envelope sender: {$this->Sender}");
$this->edebug("To: {$to}");
$this->edebug("Subject: {$subject}");
$this->edebug("Headers: {$header}");
if (!$this->UseSendmailOptions || null === $params) {
$result = @mail($to, $subject, $body, $header);
$this->edebug("Additional params: {$params}");
$result = @mail($to, $subject, $body, $header, $params);
$this->edebug('Result: ' . ($result ? 'true' : 'false'));
* Output debugging info via a user-defined method.
* Only generates output if debug output is enabled.
* @see PHPMailer::$Debugoutput
* @see PHPMailer::$SMTPDebug
protected function edebug($str)
if ($this->SMTPDebug <= 0) {
//Is this a PSR-3 logger?
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
$this->Debugoutput->debug($str);
//Avoid clash with built-in function names
if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) {
call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
switch ($this->Debugoutput) {
/** @noinspection ForgottenDebugOutputInspection */
//Cleans up output a bit for a better looking, HTML-safe output
preg_replace('/[\r\n]+/', '', $str),
$str = preg_replace('/\r\n|\r/m', "\n", $str);
echo gmdate('Y-m-d H:i:s'),
//Indent for readability, except for trailing break
* Sets message type to HTML or plain.
* @param bool $isHtml True for HTML mode
public function isHTML($isHtml = true)
$this->ContentType = static::CONTENT_TYPE_TEXT_HTML;
$this->ContentType = static::CONTENT_TYPE_PLAINTEXT;
* Send messages using SMTP.
* Send messages using PHP's mail() function.
* Send messages using $Sendmail.
public function isSendmail()
$ini_sendmail_path = ini_get('sendmail_path');
if (false === stripos($ini_sendmail_path, 'sendmail')) {
$this->Sendmail = '/usr/sbin/sendmail';
$this->Sendmail = $ini_sendmail_path;
$this->Mailer = 'sendmail';
* Send messages using qmail.
public function isQmail()
$ini_sendmail_path = ini_get('sendmail_path');