| Línea 11... |
Línea 11... |
| 11 |
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
11 |
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
|
| 12 |
* @author Brent R. Matzelle (original founder)
|
12 |
* @author Brent R. Matzelle (original founder)
|
| 13 |
* @copyright 2012 - 2020 Marcus Bointon
|
13 |
* @copyright 2012 - 2020 Marcus Bointon
|
| 14 |
* @copyright 2010 - 2012 Jim Jagielski
|
14 |
* @copyright 2010 - 2012 Jim Jagielski
|
| 15 |
* @copyright 2004 - 2009 Andy Prevost
|
15 |
* @copyright 2004 - 2009 Andy Prevost
|
| 16 |
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
16 |
* @license https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html GNU Lesser General Public License
|
| 17 |
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
17 |
* @note This program is distributed in the hope that it will be useful - WITHOUT
|
| 18 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
18 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 19 |
* FITNESS FOR A PARTICULAR PURPOSE.
|
19 |
* FITNESS FOR A PARTICULAR PURPOSE.
|
| 20 |
*/
|
20 |
*/
|
| Línea 150... |
Línea 150... |
| 150 |
/**
|
150 |
/**
|
| 151 |
* An iCal message part body.
|
151 |
* An iCal message part body.
|
| 152 |
* Only supported in simple alt or alt_inline message types
|
152 |
* Only supported in simple alt or alt_inline message types
|
| 153 |
* To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator.
|
153 |
* To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator.
|
| 154 |
*
|
154 |
*
|
| 155 |
* @see http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
|
- |
|
| 156 |
* @see http://kigkonsult.se/iCalcreator/
|
155 |
* @see https://kigkonsult.se/iCalcreator/
|
| 157 |
*
|
156 |
*
|
| 158 |
* @var string
|
157 |
* @var string
|
| 159 |
*/
|
158 |
*/
|
| 160 |
public $Ical = '';
|
159 |
public $Ical = '';
|
| Línea 252... |
Línea 251... |
| 252 |
* An ID to be used in the Message-ID header.
|
251 |
* An ID to be used in the Message-ID header.
|
| 253 |
* If empty, a unique id will be generated.
|
252 |
* If empty, a unique id will be generated.
|
| 254 |
* You can set your own, but it must be in the format "<id@domain>",
|
253 |
* You can set your own, but it must be in the format "<id@domain>",
|
| 255 |
* as defined in RFC5322 section 3.6.4 or it will be ignored.
|
254 |
* as defined in RFC5322 section 3.6.4 or it will be ignored.
|
| 256 |
*
|
255 |
*
|
| 257 |
* @see https://tools.ietf.org/html/rfc5322#section-3.6.4
|
256 |
* @see https://www.rfc-editor.org/rfc/rfc5322#section-3.6.4
|
| 258 |
*
|
257 |
*
|
| 259 |
* @var string
|
258 |
* @var string
|
| 260 |
*/
|
259 |
*/
|
| 261 |
public $MessageID = '';
|
260 |
public $MessageID = '';
|
| Línea 356... |
Línea 355... |
| 356 |
* @var string
|
355 |
* @var string
|
| 357 |
*/
|
356 |
*/
|
| 358 |
public $AuthType = '';
|
357 |
public $AuthType = '';
|
| Línea 359... |
Línea 358... |
| 359 |
|
358 |
|
| 360 |
/**
|
359 |
/**
|
| 361 |
* SMTP SMTPXClient command attibutes
|
360 |
* SMTP SMTPXClient command attributes
|
| 362 |
*
|
361 |
*
|
| 363 |
* @var array
|
362 |
* @var array
|
| 364 |
*/
|
363 |
*/
|
| Línea 386... |
Línea 385... |
| 386 |
* 'SUCCESS' will notify you when your mail has arrived at its destination.
|
385 |
* 'SUCCESS' will notify you when your mail has arrived at its destination.
|
| 387 |
* 'FAILURE' will arrive if an error occurred during delivery.
|
386 |
* 'FAILURE' will arrive if an error occurred during delivery.
|
| 388 |
* 'DELAY' will notify you if there is an unusual delay in delivery, but the actual
|
387 |
* 'DELAY' will notify you if there is an unusual delay in delivery, but the actual
|
| 389 |
* delivery's outcome (success or failure) is not yet decided.
|
388 |
* delivery's outcome (success or failure) is not yet decided.
|
| 390 |
*
|
389 |
*
|
| 391 |
* @see https://tools.ietf.org/html/rfc3461 See section 4.1 for more information about NOTIFY
|
390 |
* @see https://www.rfc-editor.org/rfc/rfc3461.html#section-4.1 for more information about NOTIFY
|
| 392 |
*/
|
391 |
*/
|
| 393 |
public $dsn = '';
|
392 |
public $dsn = '';
|
| Línea 394... |
Línea 393... |
| 394 |
|
393 |
|
| 395 |
/**
|
394 |
/**
|
| Línea 466... |
Línea 465... |
| 466 |
/**
|
465 |
/**
|
| 467 |
* Whether to generate VERP addresses on send.
|
466 |
* Whether to generate VERP addresses on send.
|
| 468 |
* Only applicable when sending via SMTP.
|
467 |
* Only applicable when sending via SMTP.
|
| 469 |
*
|
468 |
*
|
| 470 |
* @see https://en.wikipedia.org/wiki/Variable_envelope_return_path
|
469 |
* @see https://en.wikipedia.org/wiki/Variable_envelope_return_path
|
| 471 |
* @see http://www.postfix.org/VERP_README.html Postfix VERP info
|
470 |
* @see https://www.postfix.org/VERP_README.html Postfix VERP info
|
| 472 |
*
|
471 |
*
|
| 473 |
* @var bool
|
472 |
* @var bool
|
| 474 |
*/
|
473 |
*/
|
| 475 |
public $do_verp = false;
|
474 |
public $do_verp = false;
|
| Línea 549... |
Línea 548... |
| 549 |
* Callback Action function name.
|
548 |
* Callback Action function name.
|
| 550 |
*
|
549 |
*
|
| 551 |
* The function that handles the result of the send email action.
|
550 |
* The function that handles the result of the send email action.
|
| 552 |
* It is called out by send() for each email sent.
|
551 |
* It is called out by send() for each email sent.
|
| 553 |
*
|
552 |
*
|
| 554 |
* Value can be any php callable: http://www.php.net/is_callable
|
553 |
* Value can be any php callable: https://www.php.net/is_callable
|
| 555 |
*
|
554 |
*
|
| 556 |
* Parameters:
|
555 |
* Parameters:
|
| 557 |
* bool $result result of the send action
|
556 |
* bool $result result of the send action
|
| 558 |
* array $to email addresses of the recipients
|
557 |
* array $to email addresses of the recipients
|
| 559 |
* array $cc cc email addresses
|
558 |
* array $cc cc email addresses
|
| 560 |
* array $bcc bcc email addresses
|
559 |
* array $bcc bcc email addresses
|
| 561 |
* string $subject the subject
|
560 |
* string $subject the subject
|
| 562 |
* string $body the email body
|
561 |
* string $body the email body
|
| Línea 755... |
Línea 754... |
| 755 |
/**
|
754 |
/**
|
| 756 |
* The PHPMailer Version number.
|
755 |
* The PHPMailer Version number.
|
| 757 |
*
|
756 |
*
|
| 758 |
* @var string
|
757 |
* @var string
|
| 759 |
*/
|
758 |
*/
|
| 760 |
const VERSION = '6.9.1';
|
759 |
const VERSION = '6.9.3';
|
| Línea 761... |
Línea 760... |
| 761 |
|
760 |
|
| 762 |
/**
|
761 |
/**
|
| 763 |
* Error severity: message only, continue processing.
|
762 |
* Error severity: message only, continue processing.
|
| 764 |
*
|
763 |
*
|
| Línea 901... |
Línea 900... |
| 901 |
if ($this->SMTPDebug <= 0) {
|
900 |
if ($this->SMTPDebug <= 0) {
|
| 902 |
return;
|
901 |
return;
|
| 903 |
}
|
902 |
}
|
| 904 |
//Is this a PSR-3 logger?
|
903 |
//Is this a PSR-3 logger?
|
| 905 |
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
|
904 |
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
|
| 906 |
$this->Debugoutput->debug($str);
|
905 |
$this->Debugoutput->debug(rtrim($str, "\r\n"));
|
| Línea 907... |
Línea 906... |
| 907 |
|
906 |
|
| 908 |
return;
|
907 |
return;
|
| 909 |
}
|
908 |
}
|
| 910 |
//Avoid clash with built-in function names
|
909 |
//Avoid clash with built-in function names
|
| Línea 1070... |
Línea 1069... |
| 1070 |
* Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer
|
1069 |
* Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer
|
| 1071 |
* can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still
|
1070 |
* can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still
|
| 1072 |
* be modified after calling this function), addition of such addresses is delayed until send().
|
1071 |
* be modified after calling this function), addition of such addresses is delayed until send().
|
| 1073 |
* Addresses that have been added already return false, but do not throw exceptions.
|
1072 |
* Addresses that have been added already return false, but do not throw exceptions.
|
| 1074 |
*
|
1073 |
*
|
| 1075 |
* @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
|
1074 |
* @param string $kind One of 'to', 'cc', 'bcc', or 'Reply-To'
|
| 1076 |
* @param string $address The email address
|
1075 |
* @param string $address The email address
|
| 1077 |
* @param string $name An optional username associated with the address
|
1076 |
* @param string $name An optional username associated with the address
|
| 1078 |
*
|
1077 |
*
|
| 1079 |
* @throws Exception
|
1078 |
* @throws Exception
|
| 1080 |
*
|
1079 |
*
|
| Línea 1210... |
Línea 1209... |
| 1210 |
* Parse and validate a string containing one or more RFC822-style comma-separated email addresses
|
1209 |
* Parse and validate a string containing one or more RFC822-style comma-separated email addresses
|
| 1211 |
* of the form "display name <address>" into an array of name/address pairs.
|
1210 |
* of the form "display name <address>" into an array of name/address pairs.
|
| 1212 |
* Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available.
|
1211 |
* Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available.
|
| 1213 |
* Note that quotes in the name part are removed.
|
1212 |
* Note that quotes in the name part are removed.
|
| 1214 |
*
|
1213 |
*
|
| 1215 |
* @see http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation
|
1214 |
* @see https://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation
|
| 1216 |
*
|
1215 |
*
|
| 1217 |
* @param string $addrstr The address list string
|
1216 |
* @param string $addrstr The address list string
|
| 1218 |
* @param bool $useimap Whether to use the IMAP extension to parse the list
|
1217 |
* @param bool $useimap Whether to use the IMAP extension to parse the list
|
| 1219 |
* @param string $charset The charset to use when decoding the address list string.
|
1218 |
* @param string $charset The charset to use when decoding the address list string.
|
| 1220 |
*
|
1219 |
*
|
| Línea 1405... |
Línea 1404... |
| 1405 |
* * numeric TLDs: `a@b.123`
|
1404 |
* * numeric TLDs: `a@b.123`
|
| 1406 |
* * unbracketed IPv4 literals: `a@192.168.0.1`
|
1405 |
* * unbracketed IPv4 literals: `a@192.168.0.1`
|
| 1407 |
* * IPv6 literals: 'first.last@[IPv6:a1::]'
|
1406 |
* * IPv6 literals: 'first.last@[IPv6:a1::]'
|
| 1408 |
* Not all of these will necessarily work for sending!
|
1407 |
* Not all of these will necessarily work for sending!
|
| 1409 |
*
|
1408 |
*
|
| 1410 |
* @see http://squiloople.com/2009/12/20/email-address-validation/
|
- |
|
| 1411 |
* @copyright 2009-2010 Michael Rushton
|
1409 |
* @copyright 2009-2010 Michael Rushton
|
| 1412 |
* Feel free to use and redistribute this code. But please keep this copyright notice.
|
1410 |
* Feel free to use and redistribute this code. But please keep this copyright notice.
|
| 1413 |
*/
|
1411 |
*/
|
| 1414 |
return (bool) preg_match(
|
1412 |
return (bool) preg_match(
|
| 1415 |
'/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
|
1413 |
'/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
|
| Línea 1732... |
Línea 1730... |
| 1732 |
}
|
1730 |
}
|
| 1733 |
$header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
|
1731 |
$header = static::stripTrailingWSP($header) . static::$LE . static::$LE;
|
| 1734 |
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
|
1732 |
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
|
| 1735 |
//A space after `-f` is optional, but there is a long history of its presence
|
1733 |
//A space after `-f` is optional, but there is a long history of its presence
|
| 1736 |
//causing problems, so we don't use one
|
1734 |
//causing problems, so we don't use one
|
| 1737 |
//Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
|
1735 |
//Exim docs: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
|
| 1738 |
//Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html
|
1736 |
//Sendmail docs: https://www.sendmail.org/~ca/email/man/sendmail.html
|
| 1739 |
//Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
|
- |
|
| 1740 |
//Example problem: https://www.drupal.org/node/1057954
|
1737 |
//Example problem: https://www.drupal.org/node/1057954
|
| Línea 1741... |
Línea 1738... |
| 1741 |
|
1738 |
|
| 1742 |
//PHP 5.6 workaround
|
1739 |
//PHP 5.6 workaround
|
| 1743 |
$sendmail_from_value = ini_get('sendmail_from');
|
1740 |
$sendmail_from_value = ini_get('sendmail_from');
|
| Línea 1872... |
Línea 1869... |
| 1872 |
*
|
1869 |
*
|
| 1873 |
* @return bool
|
1870 |
* @return bool
|
| 1874 |
*/
|
1871 |
*/
|
| 1875 |
protected static function isPermittedPath($path)
|
1872 |
protected static function isPermittedPath($path)
|
| 1876 |
{
|
1873 |
{
|
| 1877 |
//Matches scheme definition from https://tools.ietf.org/html/rfc3986#section-3.1
|
1874 |
//Matches scheme definition from https://www.rfc-editor.org/rfc/rfc3986#section-3.1
|
| 1878 |
return !preg_match('#^[a-z][a-z\d+.-]*://#i', $path);
|
1875 |
return !preg_match('#^[a-z][a-z\d+.-]*://#i', $path);
|
| 1879 |
}
|
1876 |
}
|
| Línea 1880... |
Línea 1877... |
| 1880 |
|
1877 |
|
| 1881 |
/**
|
1878 |
/**
|
| Línea 1899... |
Línea 1896... |
| 1899 |
}
|
1896 |
}
|
| Línea 1900... |
Línea 1897... |
| 1900 |
|
1897 |
|
| 1901 |
/**
|
1898 |
/**
|
| 1902 |
* Send mail using the PHP mail() function.
|
1899 |
* Send mail using the PHP mail() function.
|
| 1903 |
*
|
1900 |
*
|
| 1904 |
* @see http://www.php.net/manual/en/book.mail.php
|
1901 |
* @see https://www.php.net/manual/en/book.mail.php
|
| 1905 |
*
|
1902 |
*
|
| 1906 |
* @param string $header The message headers
|
1903 |
* @param string $header The message headers
|
| 1907 |
* @param string $body The message body
|
1904 |
* @param string $body The message body
|
| 1908 |
*
|
1905 |
*
|
| Línea 1929... |
Línea 1926... |
| 1929 |
|
1926 |
|
| 1930 |
$params = null;
|
1927 |
$params = null;
|
| 1931 |
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
|
1928 |
//This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
|
| 1932 |
//A space after `-f` is optional, but there is a long history of its presence
|
1929 |
//A space after `-f` is optional, but there is a long history of its presence
|
| 1933 |
//causing problems, so we don't use one
|
1930 |
//causing problems, so we don't use one
|
| 1934 |
//Exim docs: http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
|
1931 |
//Exim docs: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
|
| 1935 |
//Sendmail docs: http://www.sendmail.org/~ca/email/man/sendmail.html
|
- |
|
| 1936 |
//Qmail docs: http://www.qmail.org/man/man8/qmail-inject.html
|
1932 |
//Sendmail docs: https://www.sendmail.org/~ca/email/man/sendmail.html
|
| 1937 |
//Example problem: https://www.drupal.org/node/1057954
|
1933 |
//Example problem: https://www.drupal.org/node/1057954
|
| Línea 1938... |
Línea 1934... |
| 1938 |
//CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
|
1934 |
//CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
|
| 1939 |
|
1935 |
|
| Línea 2707... |
Línea 2703... |
| 2707 |
if ('mail' !== $this->Mailer) {
|
2703 |
if ('mail' !== $this->Mailer) {
|
| 2708 |
$result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
|
2704 |
$result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
|
| 2709 |
}
|
2705 |
}
|
| Línea 2710... |
Línea 2706... |
| 2710 |
|
2706 |
|
| 2711 |
//Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4
|
2707 |
//Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4
|
| 2712 |
//https://tools.ietf.org/html/rfc5322#section-3.6.4
|
2708 |
//https://www.rfc-editor.org/rfc/rfc5322#section-3.6.4
|
| 2713 |
if (
|
2709 |
if (
|
| 2714 |
'' !== $this->MessageID &&
|
2710 |
'' !== $this->MessageID &&
|
| 2715 |
preg_match(
|
2711 |
preg_match(
|
| 2716 |
'/^<((([a-z\d!#$%&\'*+\/=?^_`{|}~-]+(\.[a-z\d!#$%&\'*+\/=?^_`{|}~-]+)*)' .
|
2712 |
'/^<((([a-z\d!#$%&\'*+\/=?^_`{|}~-]+(\.[a-z\d!#$%&\'*+\/=?^_`{|}~-]+)*)' .
|
| Línea 3632... |
Línea 3628... |
| 3632 |
/**
|
3628 |
/**
|
| 3633 |
* Encode and wrap long multibyte strings for mail headers
|
3629 |
* Encode and wrap long multibyte strings for mail headers
|
| 3634 |
* without breaking lines within a character.
|
3630 |
* without breaking lines within a character.
|
| 3635 |
* Adapted from a function by paravoid.
|
3631 |
* Adapted from a function by paravoid.
|
| 3636 |
*
|
3632 |
*
|
| 3637 |
* @see http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
|
3633 |
* @see https://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
|
| 3638 |
*
|
3634 |
*
|
| 3639 |
* @param string $str multi-byte text to wrap encode
|
3635 |
* @param string $str multi-byte text to wrap encode
|
| 3640 |
* @param string $linebreak string to use as linefeed/end-of-line
|
3636 |
* @param string $linebreak string to use as linefeed/end-of-line
|
| 3641 |
*
|
3637 |
*
|
| 3642 |
* @return string
|
3638 |
* @return string
|
| Línea 3688... |
Línea 3684... |
| 3688 |
}
|
3684 |
}
|
| Línea 3689... |
Línea 3685... |
| 3689 |
|
3685 |
|
| 3690 |
/**
|
3686 |
/**
|
| 3691 |
* Encode a string using Q encoding.
|
3687 |
* Encode a string using Q encoding.
|
| 3692 |
*
|
3688 |
*
|
| 3693 |
* @see http://tools.ietf.org/html/rfc2047#section-4.2
|
3689 |
* @see https://www.rfc-editor.org/rfc/rfc2047#section-4.2
|
| 3694 |
*
|
3690 |
*
|
| 3695 |
* @param string $str the text to encode
|
3691 |
* @param string $str the text to encode
|
| 3696 |
* @param string $position Where the text is going to be used, see the RFC for what that means
|
3692 |
* @param string $position Where the text is going to be used, see the RFC for what that means
|
| 3697 |
*
|
3693 |
*
|
| Línea 4226... |
Línea 4222... |
| 4226 |
$result = $this->Hostname;
|
4222 |
$result = $this->Hostname;
|
| 4227 |
} elseif (isset($_SERVER) && array_key_exists('SERVER_NAME', $_SERVER)) {
|
4223 |
} elseif (isset($_SERVER) && array_key_exists('SERVER_NAME', $_SERVER)) {
|
| 4228 |
$result = $_SERVER['SERVER_NAME'];
|
4224 |
$result = $_SERVER['SERVER_NAME'];
|
| 4229 |
} elseif (function_exists('gethostname') && gethostname() !== false) {
|
4225 |
} elseif (function_exists('gethostname') && gethostname() !== false) {
|
| 4230 |
$result = gethostname();
|
4226 |
$result = gethostname();
|
| 4231 |
} elseif (php_uname('n') !== false) {
|
4227 |
} elseif (php_uname('n') !== '') {
|
| 4232 |
$result = php_uname('n');
|
4228 |
$result = php_uname('n');
|
| 4233 |
}
|
4229 |
}
|
| 4234 |
if (!static::isValidHost($result)) {
|
4230 |
if (!static::isValidHost($result)) {
|
| 4235 |
return 'localhost.localdomain';
|
4231 |
return 'localhost.localdomain';
|
| 4236 |
}
|
4232 |
}
|
| Línea 4251... |
Línea 4247... |
| 4251 |
//Simple syntax limits
|
4247 |
//Simple syntax limits
|
| 4252 |
if (
|
4248 |
if (
|
| 4253 |
empty($host)
|
4249 |
empty($host)
|
| 4254 |
|| !is_string($host)
|
4250 |
|| !is_string($host)
|
| 4255 |
|| strlen($host) > 256
|
4251 |
|| strlen($host) > 256
|
| 4256 |
|| !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+\])$/', $host)
|
4252 |
|| !preg_match('/^([a-z\d.-]*|\[[a-f\d:]+\])$/i', $host)
|
| 4257 |
) {
|
4253 |
) {
|
| 4258 |
return false;
|
4254 |
return false;
|
| 4259 |
}
|
4255 |
}
|
| 4260 |
//Looks like a bracketed IPv6 address
|
4256 |
//Looks like a bracketed IPv6 address
|
| 4261 |
if (strlen($host) > 2 && substr($host, 0, 1) === '[' && substr($host, -1, 1) === ']') {
|
4257 |
if (strlen($host) > 2 && substr($host, 0, 1) === '[' && substr($host, -1, 1) === ']') {
|
| Línea 4265... |
Línea 4261... |
| 4265 |
//Need to check this first because otherwise things like `999.0.0.0` are considered valid host names
|
4261 |
//Need to check this first because otherwise things like `999.0.0.0` are considered valid host names
|
| 4266 |
if (is_numeric(str_replace('.', '', $host))) {
|
4262 |
if (is_numeric(str_replace('.', '', $host))) {
|
| 4267 |
//Is it a valid IPv4 address?
|
4263 |
//Is it a valid IPv4 address?
|
| 4268 |
return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
|
4264 |
return filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false;
|
| 4269 |
}
|
4265 |
}
|
| 4270 |
//Is it a syntactically valid hostname (when embeded in a URL)?
|
4266 |
//Is it a syntactically valid hostname (when embedded in a URL)?
|
| 4271 |
return filter_var('http://' . $host, FILTER_VALIDATE_URL) !== false;
|
4267 |
return filter_var('https://' . $host, FILTER_VALIDATE_URL) !== false;
|
| 4272 |
}
|
4268 |
}
|
| Línea 4273... |
Línea 4269... |
| 4273 |
|
4269 |
|
| 4274 |
/**
|
4270 |
/**
|
| 4275 |
* Get an error message in the current language.
|
4271 |
* Get an error message in the current language.
|
| Línea 4677... |
Línea 4673... |
| 4677 |
|
4673 |
|
| 4678 |
/**
|
4674 |
/**
|
| 4679 |
* Multi-byte-safe pathinfo replacement.
|
4675 |
* Multi-byte-safe pathinfo replacement.
|
| 4680 |
* Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe.
|
4676 |
* Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe.
|
| 4681 |
*
|
4677 |
*
|
| 4682 |
* @see http://www.php.net/manual/en/function.pathinfo.php#107461
|
4678 |
* @see https://www.php.net/manual/en/function.pathinfo.php#107461
|
| 4683 |
*
|
4679 |
*
|
| 4684 |
* @param string $path A filename or path, does not need to exist as a file
|
4680 |
* @param string $path A filename or path, does not need to exist as a file
|
| 4685 |
* @param int|string $options Either a PATHINFO_* constant,
|
4681 |
* @param int|string $options Either a PATHINFO_* constant,
|
| 4686 |
* or a string name to return only the specified piece
|
4682 |
* or a string name to return only the specified piece
|
| Línea 4912... |
Línea 4908... |
| 4912 |
/**
|
4908 |
/**
|
| 4913 |
* Generate a DKIM canonicalization header.
|
4909 |
* Generate a DKIM canonicalization header.
|
| 4914 |
* Uses the 'relaxed' algorithm from RFC6376 section 3.4.2.
|
4910 |
* Uses the 'relaxed' algorithm from RFC6376 section 3.4.2.
|
| 4915 |
* Canonicalized headers should *always* use CRLF, regardless of mailer setting.
|
4911 |
* Canonicalized headers should *always* use CRLF, regardless of mailer setting.
|
| 4916 |
*
|
4912 |
*
|
| 4917 |
* @see https://tools.ietf.org/html/rfc6376#section-3.4.2
|
4913 |
* @see https://www.rfc-editor.org/rfc/rfc6376#section-3.4.2
|
| 4918 |
*
|
4914 |
*
|
| 4919 |
* @param string $signHeader Header
|
4915 |
* @param string $signHeader Header
|
| 4920 |
*
|
4916 |
*
|
| 4921 |
* @return string
|
4917 |
* @return string
|
| 4922 |
*/
|
4918 |
*/
|
| Línea 4924... |
Línea 4920... |
| 4924 |
{
|
4920 |
{
|
| 4925 |
//Normalize breaks to CRLF (regardless of the mailer)
|
4921 |
//Normalize breaks to CRLF (regardless of the mailer)
|
| 4926 |
$signHeader = static::normalizeBreaks($signHeader, self::CRLF);
|
4922 |
$signHeader = static::normalizeBreaks($signHeader, self::CRLF);
|
| 4927 |
//Unfold header lines
|
4923 |
//Unfold header lines
|
| 4928 |
//Note PCRE \s is too broad a definition of whitespace; RFC5322 defines it as `[ \t]`
|
4924 |
//Note PCRE \s is too broad a definition of whitespace; RFC5322 defines it as `[ \t]`
|
| 4929 |
//@see https://tools.ietf.org/html/rfc5322#section-2.2
|
4925 |
//@see https://www.rfc-editor.org/rfc/rfc5322#section-2.2
|
| 4930 |
//That means this may break if you do something daft like put vertical tabs in your headers.
|
4926 |
//That means this may break if you do something daft like put vertical tabs in your headers.
|
| 4931 |
$signHeader = preg_replace('/\r\n[ \t]+/', ' ', $signHeader);
|
4927 |
$signHeader = preg_replace('/\r\n[ \t]+/', ' ', $signHeader);
|
| 4932 |
//Break headers out into an array
|
4928 |
//Break headers out into an array
|
| 4933 |
$lines = explode(self::CRLF, $signHeader);
|
4929 |
$lines = explode(self::CRLF, $signHeader);
|
| 4934 |
foreach ($lines as $key => $line) {
|
4930 |
foreach ($lines as $key => $line) {
|
| Línea 4956... |
Línea 4952... |
| 4956 |
/**
|
4952 |
/**
|
| 4957 |
* Generate a DKIM canonicalization body.
|
4953 |
* Generate a DKIM canonicalization body.
|
| 4958 |
* Uses the 'simple' algorithm from RFC6376 section 3.4.3.
|
4954 |
* Uses the 'simple' algorithm from RFC6376 section 3.4.3.
|
| 4959 |
* Canonicalized bodies should *always* use CRLF, regardless of mailer setting.
|
4955 |
* Canonicalized bodies should *always* use CRLF, regardless of mailer setting.
|
| 4960 |
*
|
4956 |
*
|
| 4961 |
* @see https://tools.ietf.org/html/rfc6376#section-3.4.3
|
4957 |
* @see https://www.rfc-editor.org/rfc/rfc6376#section-3.4.3
|
| 4962 |
*
|
4958 |
*
|
| 4963 |
* @param string $body Message Body
|
4959 |
* @param string $body Message Body
|
| 4964 |
*
|
4960 |
*
|
| 4965 |
* @return string
|
4961 |
* @return string
|
| 4966 |
*/
|
4962 |
*/
|
| Línea 4992... |
Línea 4988... |
| 4992 |
$DKIMsignatureType = 'rsa-sha256'; //Signature & hash algorithms
|
4988 |
$DKIMsignatureType = 'rsa-sha256'; //Signature & hash algorithms
|
| 4993 |
$DKIMcanonicalization = 'relaxed/simple'; //Canonicalization methods of header & body
|
4989 |
$DKIMcanonicalization = 'relaxed/simple'; //Canonicalization methods of header & body
|
| 4994 |
$DKIMquery = 'dns/txt'; //Query method
|
4990 |
$DKIMquery = 'dns/txt'; //Query method
|
| 4995 |
$DKIMtime = time();
|
4991 |
$DKIMtime = time();
|
| 4996 |
//Always sign these headers without being asked
|
4992 |
//Always sign these headers without being asked
|
| 4997 |
//Recommended list from https://tools.ietf.org/html/rfc6376#section-5.4.1
|
4993 |
//Recommended list from https://www.rfc-editor.org/rfc/rfc6376#section-5.4.1
|
| 4998 |
$autoSignHeaders = [
|
4994 |
$autoSignHeaders = [
|
| 4999 |
'from',
|
4995 |
'from',
|
| 5000 |
'to',
|
4996 |
'to',
|
| 5001 |
'cc',
|
4997 |
'cc',
|
| 5002 |
'date',
|
4998 |
'date',
|
| Línea 5098... |
Línea 5094... |
| 5098 |
if ('' !== $this->DKIM_identity) {
|
5094 |
if ('' !== $this->DKIM_identity) {
|
| 5099 |
$ident = ' i=' . $this->DKIM_identity . ';' . static::$LE;
|
5095 |
$ident = ' i=' . $this->DKIM_identity . ';' . static::$LE;
|
| 5100 |
}
|
5096 |
}
|
| 5101 |
//The DKIM-Signature header is included in the signature *except for* the value of the `b` tag
|
5097 |
//The DKIM-Signature header is included in the signature *except for* the value of the `b` tag
|
| 5102 |
//which is appended after calculating the signature
|
5098 |
//which is appended after calculating the signature
|
| 5103 |
//https://tools.ietf.org/html/rfc6376#section-3.5
|
5099 |
//https://www.rfc-editor.org/rfc/rfc6376#section-3.5
|
| 5104 |
$dkimSignatureHeader = 'DKIM-Signature: v=1;' .
|
5100 |
$dkimSignatureHeader = 'DKIM-Signature: v=1;' .
|
| 5105 |
' d=' . $this->DKIM_domain . ';' .
|
5101 |
' d=' . $this->DKIM_domain . ';' .
|
| 5106 |
' s=' . $this->DKIM_selector . ';' . static::$LE .
|
5102 |
' s=' . $this->DKIM_selector . ';' . static::$LE .
|
| 5107 |
' a=' . $DKIMsignatureType . ';' .
|
5103 |
' a=' . $DKIMsignatureType . ';' .
|
| 5108 |
' q=' . $DKIMquery . ';' .
|
5104 |
' q=' . $DKIMquery . ';' .
|