ZwiiCMS/core/vendor/phpmailer/phpmailer.php

4624 lines
155 KiB
PHP
Raw Normal View History

2019-02-20 18:35:27 +01:00
<?php
/**
* PHPMailer - PHP email creation and transport class.
2019-02-28 12:46:38 +01:00
* PHP Version 5.5.
*
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
2019-02-20 18:35:27 +01:00
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
2019-02-28 12:46:38 +01:00
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
2019-02-20 18:35:27 +01:00
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
2019-02-28 12:46:38 +01:00
namespace PHPMailer\PHPMailer;
2019-02-20 18:35:27 +01:00
/**
* PHPMailer - PHP email creation and transport class.
2019-02-28 12:46:38 +01:00
*
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
2019-02-20 18:35:27 +01:00
*/
class PHPMailer
{
2019-02-28 12:46:38 +01:00
const CHARSET_ISO88591 = 'iso-8859-1';
const CHARSET_UTF8 = 'utf-8';
const CONTENT_TYPE_PLAINTEXT = 'text/plain';
const CONTENT_TYPE_TEXT_CALENDAR = 'text/calendar';
const CONTENT_TYPE_TEXT_HTML = 'text/html';
const CONTENT_TYPE_MULTIPART_ALTERNATIVE = 'multipart/alternative';
const CONTENT_TYPE_MULTIPART_MIXED = 'multipart/mixed';
const CONTENT_TYPE_MULTIPART_RELATED = 'multipart/related';
const ENCODING_7BIT = '7bit';
const ENCODING_8BIT = '8bit';
const ENCODING_BASE64 = 'base64';
const ENCODING_BINARY = 'binary';
const ENCODING_QUOTED_PRINTABLE = 'quoted-printable';
2019-02-20 18:35:27 +01:00
/**
* Email priority.
* Options: null (default), 1 = High, 3 = Normal, 5 = low.
* When null, the header is not set at all.
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
2019-02-28 12:46:38 +01:00
public $Priority;
2019-02-20 18:35:27 +01:00
/**
* The character set of the message.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
2019-02-28 12:46:38 +01:00
public $CharSet = self::CHARSET_ISO88591;
2019-02-20 18:35:27 +01:00
/**
* The MIME Content-type of the message.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
2019-02-28 12:46:38 +01:00
public $ContentType = self::CONTENT_TYPE_PLAINTEXT;
2019-02-20 18:35:27 +01:00
/**
* The message encoding.
* Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
2019-02-28 12:46:38 +01:00
public $Encoding = self::ENCODING_8BIT;
2019-02-20 18:35:27 +01:00
/**
* Holds the most recent mailer error message.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $ErrorInfo = '';
/**
* The From email address for the message.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $From = 'root@localhost';
/**
* The From name of the message.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $FromName = 'Root User';
/**
2019-02-28 12:46:38 +01:00
* The envelope sender of the message.
* This will usually be turned into a Return-Path header by the receiver,
* and is the address that bounces will be sent to.
* If not empty, will be passed via `-f` to sendmail or as the 'MAIL FROM' value over SMTP.
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Sender = '';
/**
* The Subject of the message.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Subject = '';
/**
* An HTML or plain text message body.
* If HTML then call isHTML(true).
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Body = '';
/**
* The plain-text message body.
* This body can be read by mail clients that do not have HTML email
* capability such as mutt & Eudora.
* Clients that can read HTML will view the normal Body.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $AltBody = '';
/**
* An iCal message part body.
* Only supported in simple alt or alt_inline message types
2019-02-28 12:46:38 +01:00
* To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator.
*
* @see http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
* @see http://kigkonsult.se/iCalcreator/
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Ical = '';
/**
* The complete compiled MIME message body.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $MIMEBody = '';
/**
* The complete compiled MIME message headers.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $MIMEHeader = '';
/**
* Extra headers that createHeader() doesn't fold in.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $mailHeader = '';
/**
* Word-wrap the message body to this number of chars.
* Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
2019-02-28 12:46:38 +01:00
*
* @see static::STD_LINE_LENGTH
*
* @var int
2019-02-20 18:35:27 +01:00
*/
public $WordWrap = 0;
/**
* Which method to use to send mail.
* Options: "mail", "sendmail", or "smtp".
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Mailer = 'mail';
/**
* The path to the sendmail program.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Sendmail = '/usr/sbin/sendmail';
/**
* Whether mail() uses a fully sendmail-compatible MTA.
* One which supports sendmail's "-oi -f" options.
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $UseSendmailOptions = true;
/**
* The email address that a reading confirmation should be sent to, also known as read receipt.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $ConfirmReadingTo = '';
/**
* The hostname to use in the Message-ID header and as default HELO string.
* If empty, PHPMailer attempts to find one with, in order,
* $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value
* 'localhost.localdomain'.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Hostname = '';
/**
* An ID to be used in the Message-ID header.
* If empty, a unique id will be generated.
* You can set your own, but it must be in the format "<id@domain>",
* as defined in RFC5322 section 3.6.4 or it will be ignored.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @see https://tools.ietf.org/html/rfc5322#section-3.6.4
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $MessageID = '';
/**
* The message Date to be used in the Date header.
* If empty, the current date will be added.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $MessageDate = '';
/**
* SMTP hosts.
* Either a single hostname or multiple semicolon-delimited hostnames.
* You can also specify a different port
* for each host by using this format: [hostname:port]
* (e.g. "smtp1.example.com:25;smtp2.example.com").
* You can also specify encryption type, for example:
* (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
* Hosts will be tried in order.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Host = 'localhost';
/**
* The default SMTP server port.
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
public $Port = 25;
/**
* The SMTP HELO of the message.
* Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find
* one with the same method described above for $Hostname.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @see PHPMailer::$Hostname
2019-02-28 12:46:38 +01:00
*
* @var string
2019-02-20 18:35:27 +01:00
*/
public $Helo = '';
/**
* What kind of encryption to use on the SMTP connection.
2019-02-28 12:46:38 +01:00
* Options: '', 'ssl' or 'tls'.
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $SMTPSecure = '';
/**
* Whether to enable TLS encryption automatically if a server supports it,
* even if `SMTPSecure` is not set to 'tls'.
* Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $SMTPAutoTLS = true;
/**
* Whether to use SMTP authentication.
* Uses the Username and Password properties.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @see PHPMailer::$Username
* @see PHPMailer::$Password
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $SMTPAuth = false;
/**
* Options array passed to stream_context_create when connecting via SMTP.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
public $SMTPOptions = [];
2019-02-20 18:35:27 +01:00
/**
* SMTP username.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Username = '';
/**
* SMTP password.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $Password = '';
/**
* SMTP auth type.
2019-02-28 12:46:38 +01:00
* Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2, attempted in that order if not specified.
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $AuthType = '';
/**
2019-02-28 12:46:38 +01:00
* An instance of the PHPMailer OAuth class.
*
* @var OAuth
2019-02-20 18:35:27 +01:00
*/
2019-02-28 12:46:38 +01:00
protected $oauth;
2019-02-20 18:35:27 +01:00
/**
* The SMTP server timeout in seconds.
2019-02-28 12:46:38 +01:00
* Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
*
* @var int
2019-02-20 18:35:27 +01:00
*/
public $Timeout = 300;
/**
* Comma separated list of DSN notifications
* 'NEVER' under no circumstances a DSN must be returned to the sender.
* If you use NEVER all other notifications will be ignored.
* 'SUCCESS' will notify you when your mail has arrived at its destination.
* 'FAILURE' will arrive if an error occurred during delivery.
* 'DELAY' will notify you if there is an unusual delay in delivery, but the actual
* delivery's outcome (success or failure) is not yet decided.
*
* @see https://tools.ietf.org/html/rfc3461 See section 4.1 for more information about NOTIFY
*/
public $dsn = '';
2019-02-20 18:35:27 +01:00
/**
* SMTP class debug output mode.
* Debug output level.
* Options:
* * `0` No output
* * `1` Commands
* * `2` Data and commands
* * `3` As 2 plus connection status
2019-02-28 12:46:38 +01:00
* * `4` Low-level data output.
*
2019-02-20 18:35:27 +01:00
* @see SMTP::$do_debug
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
public $SMTPDebug = 0;
/**
* How to handle debug output.
* Options:
* * `echo` Output plain-text as-is, appropriate for CLI
* * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
* * `error_log` Output to error log as configured in php.ini
2019-02-28 12:46:38 +01:00
* By default PHPMailer will use `echo` if run from a `cli` or `cli-server` SAPI, `html` otherwise.
2019-02-20 18:35:27 +01:00
* Alternatively, you can provide a callable expecting two params: a message string and the debug level:
2019-02-28 12:46:38 +01:00
*
* ```php
2019-02-20 18:35:27 +01:00
* $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
2019-02-28 12:46:38 +01:00
* ```
*
* Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only `debug`
* level output is used:
*
* ```php
* $mail->Debugoutput = new myPsr3Logger;
* ```
*
2019-02-20 18:35:27 +01:00
* @see SMTP::$Debugoutput
2019-02-28 12:46:38 +01:00
*
* @var string|callable|\Psr\Log\LoggerInterface
2019-02-20 18:35:27 +01:00
*/
public $Debugoutput = 'echo';
/**
* Whether to keep SMTP connection open after each message.
* If this is set to true then to close the connection
* requires an explicit call to smtpClose().
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $SMTPKeepAlive = false;
/**
* Whether to split multiple to addresses into multiple messages
* or send them all in one message.
* Only supported in `mail` and `sendmail` transports, not in SMTP.
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $SingleTo = false;
/**
* Storage for addresses when SingleTo is enabled.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $SingleToArray = [];
2019-02-20 18:35:27 +01:00
/**
* Whether to generate VERP addresses on send.
* Only applicable when sending via SMTP.
2019-02-28 12:46:38 +01:00
*
* @see https://en.wikipedia.org/wiki/Variable_envelope_return_path
* @see http://www.postfix.org/VERP_README.html Postfix VERP info
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $do_verp = false;
/**
* Whether to allow sending messages with an empty body.
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
public $AllowEmpty = false;
/**
* DKIM selector.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $DKIM_selector = '';
/**
* DKIM Identity.
* Usually the email address used as the source of the email.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $DKIM_identity = '';
/**
* DKIM passphrase.
* Used if your key is encrypted.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $DKIM_passphrase = '';
/**
* DKIM signing domain name.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @example 'example.com'
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $DKIM_domain = '';
2019-02-28 12:46:38 +01:00
/**
* DKIM Copy header field values for diagnostic use.
*
* @var bool
*/
public $DKIM_copyHeaderFields = true;
/**
* DKIM Extra signing headers.
*
* @example ['List-Unsubscribe', 'List-Help']
*
* @var array
*/
public $DKIM_extraHeaders = [];
2019-02-20 18:35:27 +01:00
/**
* DKIM private key file path.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $DKIM_private = '';
/**
* DKIM private key string.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* If set, takes precedence over `$DKIM_private`.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
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
*
* Parameters:
2019-02-28 12:46:38 +01:00
* bool $result result of the send action
2019-02-20 18:35:27 +01:00
* 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
2019-02-28 12:46:38 +01:00
* string $extra extra information of possible use
* "smtp_transaction_id' => last smtp transaction id
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $action_function = '';
/**
* What to put in the X-Mailer header.
2019-02-28 12:46:38 +01:00
* Options: An empty string for PHPMailer default, whitespace for none, or a string to use.
*
2019-02-20 18:35:27 +01:00
* @var string
*/
public $XMailer = '';
/**
* 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.
2019-02-28 12:46:38 +01:00
* The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option.
*
2019-02-20 18:35:27 +01:00
* @see PHPMailer::validateAddress()
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string|callable
*/
2019-02-28 12:46:38 +01:00
public static $validator = 'php';
2019-02-20 18:35:27 +01:00
/**
* An instance of the SMTP sender class.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var SMTP
*/
2019-02-28 12:46:38 +01:00
protected $smtp;
2019-02-20 18:35:27 +01:00
/**
* The array of 'to' names and addresses.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $to = [];
2019-02-20 18:35:27 +01:00
/**
* The array of 'cc' names and addresses.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $cc = [];
2019-02-20 18:35:27 +01:00
/**
* The array of 'bcc' names and addresses.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $bcc = [];
2019-02-20 18:35:27 +01:00
/**
* The array of reply-to names and addresses.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $ReplyTo = [];
2019-02-20 18:35:27 +01:00
/**
* An array of all kinds of addresses.
2019-02-28 12:46:38 +01:00
* Includes all of $to, $cc, $bcc.
*
* @see PHPMailer::$to
* @see PHPMailer::$cc
* @see PHPMailer::$bcc
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $all_recipients = [];
2019-02-20 18:35:27 +01:00
/**
* 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.
2019-02-28 12:46:38 +01:00
*
* @see PHPMailer::$to
* @see PHPMailer::$cc
* @see PHPMailer::$bcc
2019-02-20 18:35:27 +01:00
* @see PHPMailer::$all_recipients
2019-02-28 12:46:38 +01:00
*
* @var array
2019-02-20 18:35:27 +01:00
*/
2019-02-28 12:46:38 +01:00
protected $RecipientsQueue = [];
2019-02-20 18:35:27 +01:00
/**
* 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.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @see PHPMailer::$ReplyTo
2019-02-28 12:46:38 +01:00
*
* @var array
2019-02-20 18:35:27 +01:00
*/
2019-02-28 12:46:38 +01:00
protected $ReplyToQueue = [];
2019-02-20 18:35:27 +01:00
/**
* The array of attachments.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $attachment = [];
2019-02-20 18:35:27 +01:00
/**
* The array of custom headers.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $CustomHeader = [];
2019-02-20 18:35:27 +01:00
/**
* The most recent Message-ID (including angular brackets).
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $lastMessageID = '';
/**
* The message's MIME type.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $message_type = '';
/**
* The array of MIME boundary strings.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $boundary = [];
2019-02-20 18:35:27 +01:00
/**
* The array of available languages.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var array
*/
2019-02-28 12:46:38 +01:00
protected $language = [];
2019-02-20 18:35:27 +01:00
/**
* The number of errors encountered.
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
protected $error_count = 0;
/**
* The S/MIME certificate file path.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $sign_cert_file = '';
/**
* The S/MIME key file path.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $sign_key_file = '';
/**
* The optional S/MIME extra certificates ("CA Chain") file path.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $sign_extracerts_file = '';
/**
* The S/MIME password for the key.
* Used only if the key is encrypted.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $sign_key_pass = '';
/**
* Whether to throw exceptions for errors.
2019-02-28 12:46:38 +01:00
*
* @var bool
2019-02-20 18:35:27 +01:00
*/
protected $exceptions = false;
/**
* Unique ID used for message ID and boundaries.
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @var string
*/
protected $uniqueid = '';
2019-02-28 12:46:38 +01:00
/**
* The PHPMailer Version number.
*
* @var string
*/
const VERSION = '6.0.7';
2019-02-28 12:46:38 +01:00
2019-02-20 18:35:27 +01:00
/**
* Error severity: message only, continue processing.
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
const STOP_MESSAGE = 0;
/**
* Error severity: message, likely ok to continue processing.
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
const STOP_CONTINUE = 1;
/**
* Error severity: message, plus full stop, critical error reached.
2019-02-28 12:46:38 +01:00
*
* @var int
2019-02-20 18:35:27 +01:00
*/
const STOP_CRITICAL = 2;
/**
* SMTP RFC standard line ending.
2019-02-28 12:46:38 +01:00
*
* @var string
2019-02-20 18:35:27 +01:00
*/
2019-02-28 12:46:38 +01:00
protected static $LE = "\r\n";
2019-02-20 18:35:27 +01:00
/**
2019-02-28 12:46:38 +01:00
* The maximum line length allowed by RFC 2822 section 2.1.1.
*
* @var int
2019-02-20 18:35:27 +01:00
*/
const MAX_LINE_LENGTH = 998;
2019-02-28 12:46:38 +01:00
/**
* 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.
*
* @var int
*/
const STD_LINE_LENGTH = 76;
2019-02-20 18:35:27 +01:00
/**
* Constructor.
2019-02-28 12:46:38 +01:00
*
* @param bool $exceptions Should we throw external exceptions?
2019-02-20 18:35:27 +01:00
*/
public function __construct($exceptions = null)
{
2019-02-28 12:46:38 +01:00
if (null !== $exceptions) {
$this->exceptions = (bool) $exceptions;
2019-02-20 18:35:27 +01:00
}
//Pick an appropriate debug output format automatically
$this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html');
}
/**
* Destructor.
*/
public function __destruct()
{
//Close any open SMTP connection nicely
$this->smtpClose();
}
/**
* 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,
2019-02-28 12:46:38 +01:00
* but it will do).
*
* @param string $to To
* @param string $subject Subject
* @param string $body Message Body
* @param string $header Additional Header(s)
* @param string|null $params Params
*
* @return bool
2019-02-20 18:35:27 +01:00
*/
private function mailPassthru($to, $subject, $body, $header, $params)
{
//Check overloading of mail function to avoid double-encoding
if (ini_get('mbstring.func_overload') & 1) {
$subject = $this->secureHeader($subject);
} else {
$subject = $this->encodeHeader($this->secureHeader($subject));
}
2019-02-28 12:46:38 +01:00
//Calling mail() with null params breaks
if (!$this->UseSendmailOptions or null === $params) {
2019-02-20 18:35:27 +01:00
$result = @mail($to, $subject, $body, $header);
} else {
$result = @mail($to, $subject, $body, $header, $params);
}
2019-02-28 12:46:38 +01:00
2019-02-20 18:35:27 +01:00
return $result;
}
2019-02-28 12:46:38 +01:00
2019-02-20 18:35:27 +01:00
/**
* Output debugging info via user-defined method.
* Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @see PHPMailer::$Debugoutput
* @see PHPMailer::$SMTPDebug
2019-02-28 12:46:38 +01:00
*
2019-02-20 18:35:27 +01:00
* @param string $str
*/
protected function edebug($str)
{
if ($this->SMTPDebug <= 0) {
return;
}
2019-02-28 12:46:38 +01:00
//Is this a PSR-3 logger?
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
$this->Debugoutput->debug($str);
return;
}
2019-02-20 18:35:27 +01:00
//Avoid clash with built-in function names
2019-02-28 12:46:38 +01:00
if (!in_array($this->Debugoutput, ['error_log', 'html', 'echo']) and is_callable($this->Debugoutput)) {
2019-02-20 18:35:27 +01:00
call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
2019-02-28 12:46:38 +01:00
2019-02-20 18:35:27 +01:00
return;
}
switch ($this->Debugoutput) {
case 'error_log':
//Don't output, just log
error_log($str);
break;
case 'html':
//Cleans up output a bit for a better looking, HTML-safe output
echo htmlentities(
preg_replace('/[\r\n]+/', '', $str),
ENT_QUOTES,
'UTF-8'
2019-02-28 12:46:38 +01:00
), "<br>\n";
2019-02-20 18:35:27 +01:00
break;
case 'echo':
default:
//Normalize line breaks
2019-02-28 12:46:38 +01:00
$str = preg_replace('/\r\n|\r/ms', "\n", $str);
echo gmdate('Y-m-d H:i:s'),
"\t",
//Trim trailing space
trim(
//Indent for readability, except for trailing break
str_replace(
"\n",
"\n \t ",
trim($str)
)
),
"\n";
2019-02-20 18:35:27 +01:00
}
}
/**
* Sets message type to HTML or plain.
2019-02-28 12:46:38 +01:00
*
* @param bool $isHtml True for HTML mode
2019-02-20 18:35:27 +01:00
*/
public function isHTML($isHtml = true)
{
if ($isHtml) {