0
0
mirror of https://github.com/PHPMailer/PHPMailer.git synced 2024-09-20 01:52:15 +02:00

Switch from PHP CS fixer to phpcs and apply PSR12 reformatting

This commit is contained in:
Marcus Bointon 2020-10-13 15:08:42 +02:00
parent 282f0fc0ce
commit 22e81749ae
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
89 changed files with 283 additions and 184 deletions

View File

@ -1,6 +1,9 @@
Before submitting your pull request, check whether your code adheres to PHPMailer Before submitting your pull request, check whether your code adheres to PHPMailer coding standards (which is mostly [PSR-12](https://www.php-fig.org/psr/psr-12/)) by running [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer):
coding standards by running the following command:
`./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix ` ./vendor/bin/phpcs
And committing eventual changes. It's important that this command uses the specific version of php-cs-fixer configured for PHPMailer, so run `composer install` within the PHPMailer folder to use the exact version it needs. Any problems reported can probably be fixed automatically by using its partner tool, PHP code beautifier:
./vendor/bin/phpcbf
It's important that this command uses the specific version of phpcs configured for PHPMailer, so run `composer install` within the PHPMailer folder to use the exact version it needs.

1
.gitignore vendored
View File

@ -6,4 +6,3 @@ build/
vendor/ vendor/
*.pem *.pem
composer.lock composer.lock
.php_cs.cache

35
.php_cs
View File

@ -1,35 +0,0 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => false,
'concat_space' => ['spacing' => 'one'],
'heredoc_to_nowdoc' => true,
'method_argument_space' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
'no_php4_constructor' => true,
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_fqcn_annotation' => false,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'semicolon_after_instruction' => true,
'simplified_null_return' => true,
'native_function_invocation' => false,
'yoda_style' => false,
'no_break_comment' => false,
'native_constant_invocation' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/test')
)
;

View File

@ -1,6 +1,6 @@
build: build:
environment: environment:
php: '5.6.0' php: '7.4.0'
before_commands: before_commands:
- "composer install --prefer-source" - "composer install --prefer-source"
@ -49,19 +49,6 @@ tools:
- test - test
- vendor - vendor
# PHP CS Fixer (http://http://cs.sensiolabs.org/).
php_cs_fixer:
enabled: true
config:
level: psr2
filter:
excluded_paths:
- 'docs/*'
- 'examples/*'
- 'extras/*'
- 'test/*'
- 'vendor/*'
# Analyzes the size and structure of a PHP project. # Analyzes the size and structure of a PHP project.
php_loc: php_loc:
enabled: true enabled: true

View File

@ -10,7 +10,6 @@ before_install:
- sudo apt-get install -y -qq postfix - sudo apt-get install -y -qq postfix
install: install:
- REMOVE_PACKAGE="friendsofphp/php-cs-fixer"; if [ "$CS_CHECK" = 1 ]; then REMOVE_PACKAGE="phpunit/phpunit"; fi; composer remove --no-update --no-scripts --dev $REMOVE_PACKAGE
- composer install - composer install
- if [ "$CODE_COVERAGE" != 1 ]; then phpenv config-rm xdebug.ini || true; fi - if [ "$CODE_COVERAGE" != 1 ]; then phpenv config-rm xdebug.ini || true; fi
@ -23,12 +22,7 @@ before_script:
- sudo mkdir -p /var/qmail/bin - sudo mkdir -p /var/qmail/bin
- sudo cp test/fakesendmail.sh /var/qmail/bin/sendmail - sudo cp test/fakesendmail.sh /var/qmail/bin/sendmail
- sudo cp test/fakesendmail.sh /usr/sbin/sendmail - sudo cp test/fakesendmail.sh /usr/sbin/sendmail
- | - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then
echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' >> /etc/hhvm/php.ini
else
echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
fi
script: ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist script: ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist
@ -43,12 +37,8 @@ stages:
jobs: jobs:
include: include:
- stage: coding-standard - stage: coding-standard
before_install: script: ./vendor/bin/phpcs -s
before_script: php: 7.4
script: ./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix
after_script:
php: 5.6
env: CS_CHECK=1
- stage: test - stage: test
- php: 7.0 - php: 7.0
- php: 7.1 - php: 7.1
@ -57,10 +47,8 @@ jobs:
- php: 7.4 - php: 7.4
env: CODE_COVERAGE=1 env: CODE_COVERAGE=1
- php: nightly - php: nightly
- php: hhvm
dist: trusty dist: trusty
matrix: matrix:
allow_failures: allow_failures:
- php: nightly - php: nightly
- php: hhvm

View File

@ -32,9 +32,12 @@
"ext-hash": "*" "ext-hash": "*"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^2.2", "squizlabs/php_codesniffer": "3.5.6",
"phpcompatibility/php-compatibility": "9.3.5",
"phpunit/phpunit": "^4.8 || ^5.7", "phpunit/phpunit": "^4.8 || ^5.7",
"doctrine/annotations": "^1.2" "doctrine/annotations": "^1.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"roave/security-advisories": "dev-latest"
}, },
"suggest": { "suggest": {
"psr/log": "For optional PSR-3 debug logging", "psr/log": "For optional PSR-3 debug logging",

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This shows how to make a new public/private key pair suitable for use with DKIM. * This shows how to make a new public/private key pair suitable for use with DKIM.
* You should only need to do this once, and the public key (**not** the private key!) * You should only need to do this once, and the public key (**not** the private key!)

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows sending a DKIM-signed message with PHPMailer. * This example shows sending a DKIM-signed message with PHPMailer.
* More info about DKIM can be found here: http://www.dkim.org/info/dkim-faq.html * More info about DKIM can be found here: http://www.dkim.org/info/dkim-faq.html
@ -14,7 +15,7 @@ use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Usual setup //Usual setup
$mail = new PHPMailer; $mail = new PHPMailer();
$mail->setFrom('from@example.com', 'First Last'); $mail->setFrom('from@example.com', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe'); $mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer mail() test'; $mail->Subject = 'PHPMailer mail() test';
@ -39,7 +40,7 @@ $mail->DKIM_extraHeaders = ['List-Unsubscribe', 'List-Help'];
//When you send, the DKIM settings will be used to sign the message //When you send, the DKIM settings will be used to sign the message
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to use a callback function from PHPMailer. * This example shows how to use a callback function from PHPMailer.
*/ */
@ -42,7 +43,7 @@ function callbackAction($result, $to, $cc, $bcc, $subject, $body)
require_once '../vendor/autoload.php'; require_once '../vendor/autoload.php';
$mail = new PHPMailer; $mail = new PHPMailer();
try { try {
$mail->isMail(); $mail->isMail();

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to handle a simple contact form safely. * This example shows how to handle a simple contact form safely.
*/ */
@ -10,7 +11,8 @@ use PHPMailer\PHPMailer\PHPMailer;
if (array_key_exists('email', $_POST)) { if (array_key_exists('email', $_POST)) {
date_default_timezone_set('Etc/UTC'); date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php'; require '../vendor/autoload.php';
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; $isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) &&
strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer(); $mail = new PHPMailer();
@ -58,8 +60,9 @@ EOT;
if (!$mail->send()) { if (!$mail->send()) {
//The reason for failing to send will be in $mail->ErrorInfo //The reason for failing to send will be in $mail->ErrorInfo
//but it's unsafe to display errors directly to users - process the error, log it on your server. //but it's unsafe to display errors directly to users - process the error, log it on your server.
if ($isAjax) if ($isAjax) {
http_response_code(500); http_response_code(500);
}
$response = [ $response = [
"status" => false, "status" => false,
@ -93,7 +96,9 @@ EOT;
</head> </head>
<body> <body>
<h1>Contact us</h1> <h1>Contact us</h1>
<h2 id="status-message"><?php if (isset($response)) { echo $response['message']; }?></h2> <h2 id="status-message"><?php if (isset($response)) {
echo $response['message'];
}?></h2>
<form method="POST" id="contact-form"> <form method="POST" id="contact-form">
<label for="name">Name: <input type="text" name="name" id="name"></label><br> <label for="name">Name: <input type="text" name="name" id="name"></label><br>
<label for="email">Email address: <input type="email" name="email" id="email"></label><br> <label for="email">Email address: <input type="email" name="email" id="email"></label><br>

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to handle a simple contact form safely. * This example shows how to handle a simple contact form safely.
*/ */

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to make use of PHPMailer's exceptions for error handling. * This example shows how to make use of PHPMailer's exceptions for error handling.
*/ */

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to extend PHPMailer to simplify your coding. * This example shows how to extend PHPMailer to simplify your coding.
* If PHPMailer doesn't do something the way you want it to, or your code * If PHPMailer doesn't do something the way you want it to, or your code
@ -17,7 +18,7 @@ require '../vendor/autoload.php';
/** /**
* Use PHPMailer as a base class and extend it * Use PHPMailer as a base class and extend it
*/ */
class myPHPMailer extends PHPMailer class MyPHPMailer extends PHPMailer
{ {
/** /**
* myPHPMailer constructor. * myPHPMailer constructor.
@ -50,7 +51,7 @@ class myPHPMailer extends PHPMailer
{ {
$this->Subject = '[Yay for me!] ' . $this->Subject; $this->Subject = '[Yay for me!] ' . $this->Subject;
$r = parent::send(); $r = parent::send();
echo 'I sent a message with subject '. $this->Subject; echo 'I sent a message with subject ' . $this->Subject;
return $r; return $r;
} }
@ -67,5 +68,5 @@ try {
$mail->send(); //no need to check for errors - the exception handler will do it $mail->send(); //no need to check for errors - the exception handler will do it
} catch (Exception $e) { } catch (Exception $e) {
//Note that this is catching the PHPMailer Exception class, not the global \Exception type! //Note that this is catching the PHPMailer Exception class, not the global \Exception type!
echo 'Caught a '. get_class($e) .': '. $e->getMessage(); echo 'Caught a ' . get_class($e) . ': ' . $e->getMessage();
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows settings to use when sending via Google's Gmail servers. * This example shows settings to use when sending via Google's Gmail servers.
* This uses traditional id & password authentication - look at the gmail_xoauth.phps * This uses traditional id & password authentication - look at the gmail_xoauth.phps
@ -13,7 +14,7 @@ use PHPMailer\PHPMailer\SMTP;
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Tell PHPMailer to use SMTP //Tell PHPMailer to use SMTP
$mail->isSMTP(); $mail->isSMTP();
@ -69,7 +70,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors //send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
//Section 2: IMAP //Section 2: IMAP

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to send via Google's Gmail servers using XOAUTH2 authentication. * This example shows how to send via Google's Gmail servers using XOAUTH2 authentication.
*/ */
@ -7,7 +8,6 @@
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\OAuth; use PHPMailer\PHPMailer\OAuth;
// Alias the League Google OAuth2 provider class // Alias the League Google OAuth2 provider class
use League\OAuth2\Client\Provider\Google; use League\OAuth2\Client\Provider\Google;
@ -20,7 +20,7 @@ date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Tell PHPMailer to use SMTP //Tell PHPMailer to use SMTP
$mail->isSMTP(); $mail->isSMTP();
@ -100,7 +100,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors //send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows sending a message using PHP's mail() function. * This example shows sending a message using PHP's mail() function.
*/ */
@ -9,7 +10,7 @@ use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Set who the message is to be sent from //Set who the message is to be sent from
$mail->setFrom('from@example.com', 'First Last'); $mail->setFrom('from@example.com', 'First Last');
//Set an alternative reply-to address //Set an alternative reply-to address
@ -28,7 +29,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors //send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to send a message to a whole list of recipients efficiently. * This example shows how to send a message to a whole list of recipients efficiently.
*/ */
@ -57,7 +58,8 @@ foreach ($result as $row) {
try { try {
$mail->send(); $mail->send();
echo 'Message sent to :' . htmlspecialchars($row['full_name']) . ' (' . htmlspecialchars($row['email']) . ')<br>'; echo 'Message sent to :' . htmlspecialchars($row['full_name']) . ' (' .
htmlspecialchars($row['email']) . ')<br>';
//Mark it as sent in the DB //Mark it as sent in the DB
mysqli_query( mysqli_query(
$mysql, $mysql,

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows how to use POP-before-SMTP for authentication. * This example shows how to use POP-before-SMTP for authentication.
* POP-before-SMTP is a very old technology that is hardly used any more. * POP-before-SMTP is a very old technology that is hardly used any more.

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer simple file upload and send example. * PHPMailer simple file upload and send example.
*/ */
@ -16,7 +17,7 @@ if (array_key_exists('userfile', $_FILES)) {
// Upload handled successfully // Upload handled successfully
// Now create a message // Now create a message
require '../vendor/autoload.php'; require '../vendor/autoload.php';
$mail = new PHPMailer; $mail = new PHPMailer();
$mail->setFrom('from@example.com', 'First Last'); $mail->setFrom('from@example.com', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe'); $mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer file sender'; $mail->Subject = 'PHPMailer file sender';
@ -26,7 +27,7 @@ if (array_key_exists('userfile', $_FILES)) {
$msg .= 'Failed to attach file ' . $_FILES['userfile']['name']; $msg .= 'Failed to attach file ' . $_FILES['userfile']['name'];
} }
if (!$mail->send()) { if (!$mail->send()) {
$msg .= 'Mailer Error: '. $mail->ErrorInfo; $msg .= 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
$msg .= 'Message sent!'; $msg .= 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer multiple files upload and send example * PHPMailer multiple files upload and send example
*/ */
@ -10,7 +11,7 @@ $msg = '';
if (array_key_exists('userfile', $_FILES)) { if (array_key_exists('userfile', $_FILES)) {
require '../vendor/autoload.php'; require '../vendor/autoload.php';
// Create a message // Create a message
$mail = new PHPMailer; $mail = new PHPMailer();
$mail->setFrom('from@example.com', 'First Last'); $mail->setFrom('from@example.com', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe'); $mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer file sender'; $mail->Subject = 'PHPMailer file sender';
@ -28,7 +29,7 @@ if (array_key_exists('userfile', $_FILES)) {
} }
} }
if (!$mail->send()) { if (!$mail->send()) {
$msg .= 'Mailer Error: '. $mail->ErrorInfo; $msg .= 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
$msg .= 'Message sent!'; $msg .= 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows sending a message using a local sendmail binary. * This example shows sending a message using a local sendmail binary.
*/ */
@ -9,7 +10,7 @@ use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport // Set PHPMailer to use the sendmail transport
$mail->isSendmail(); $mail->isSendmail();
//Set who the message is to be sent from //Set who the message is to be sent from
@ -30,7 +31,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors //send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer simple contact form example. * PHPMailer simple contact form example.
* If you want to accept and send uploads in your form, look at the send_file_upload example. * If you want to accept and send uploads in your form, look at the send_file_upload example.
@ -51,7 +52,7 @@ if (array_key_exists('to', $_POST)) {
$err = true; $err = true;
} }
if (!$err) { if (!$err) {
$mail = new PHPMailer; $mail = new PHPMailer();
$mail->isSMTP(); $mail->isSMTP();
$mail->Host = 'localhost'; $mail->Host = 'localhost';
$mail->Port = 25; $mail->Port = 25;
@ -65,7 +66,7 @@ if (array_key_exists('to', $_POST)) {
$mail->Subject = 'Contact form: ' . $subject; $mail->Subject = 'Contact form: ' . $subject;
$mail->Body = "Contact form submission\n\n" . $query; $mail->Body = "Contact form submission\n\n" . $query;
if (!$mail->send()) { if (!$mail->send()) {
$msg .= 'Mailer Error: '. $mail->ErrorInfo; $msg .= 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
$msg .= 'Message sent!'; $msg .= 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This PHPMailer example shows S/MIME signing a message and then sending. * This PHPMailer example shows S/MIME signing a message and then sending.
* *
@ -53,7 +54,7 @@ use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Set who the message is to be sent from //Set who the message is to be sent from
//IMPORTANT: This must match the email address of your certificate. //IMPORTANT: This must match the email address of your certificate.
//Although the certificate will be valid, an error will be thrown since it cannot be verified //Although the certificate will be valid, an error will be thrown since it cannot be verified
@ -85,7 +86,7 @@ $mail->sign(
//Send the message, check for errors //Send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows making an SMTP connection with authentication. * This example shows making an SMTP connection with authentication.
*/ */
@ -14,7 +15,7 @@ date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Tell PHPMailer to use SMTP //Tell PHPMailer to use SMTP
$mail->isSMTP(); $mail->isSMTP();
//Enable SMTP debugging //Enable SMTP debugging

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This uses the SMTP class alone to check that a connection can be made to an SMTP server, * This uses the SMTP class alone to check that a connection can be made to an SMTP server,
* authenticate, then disconnect * authenticate, then disconnect
@ -15,7 +16,7 @@ require '../vendor/autoload.php';
date_default_timezone_set('Etc/UTC'); date_default_timezone_set('Etc/UTC');
//Create a new SMTP instance //Create a new SMTP instance
$smtp = new SMTP; $smtp = new SMTP();
//Enable connection-level debug output //Enable connection-level debug output
$smtp->do_debug = SMTP::DEBUG_CONNECTION; $smtp->do_debug = SMTP::DEBUG_CONNECTION;

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* SMTP low memory example. * SMTP low memory example.
*/ */
@ -122,7 +123,7 @@ class PHPMailerLowMemory extends PHPMailer
public function getSMTPInstance() public function getSMTPInstance()
{ {
if (!is_object($this->smtp)) { if (!is_object($this->smtp)) {
$this->smtp = new SMTPLowMemory; $this->smtp = new SMTPLowMemory();
} }
return $this->smtp; return $this->smtp;

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows making an SMTP connection without using authentication. * This example shows making an SMTP connection without using authentication.
*/ */
@ -14,7 +15,7 @@ date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Tell PHPMailer to use SMTP //Tell PHPMailer to use SMTP
$mail->isSMTP(); $mail->isSMTP();
//Enable SMTP debugging //Enable SMTP debugging
@ -46,7 +47,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors //send the message, check for errors
if (!$mail->send()) { if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo; echo 'Mailer Error: ' . $mail->ErrorInfo;
} else { } else {
echo 'Message sent!'; echo 'Message sent!';
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* This example shows settings to use when sending over SMTP with TLS and custom connection options. * This example shows settings to use when sending over SMTP with TLS and custom connection options.
*/ */
@ -14,7 +15,7 @@ date_default_timezone_set('Etc/UTC');
require '../vendor/autoload.php'; require '../vendor/autoload.php';
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new PHPMailer; $mail = new PHPMailer();
//Tell PHPMailer to use SMTP //Tell PHPMailer to use SMTP
$mail->isSMTP(); $mail->isSMTP();

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Afrikaans PHPMailer language file: refer to English translation for definitive list * Afrikaans PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Arabic PHPMailer language file: refer to English translation for definitive list * Arabic PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Azerbaijani PHPMailer language file: refer to English translation for definitive list * Azerbaijani PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Bosnian PHPMailer language file: refer to English translation for definitive list * Bosnian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer
@ -23,4 +24,4 @@ $PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Spajanje na SMTP server nije uspjelo.'; $PHPMAILER_LANG['smtp_connect_failed'] = 'Spajanje na SMTP server nije uspjelo.';
$PHPMAILER_LANG['smtp_error'] = 'SMTP greška: '; $PHPMAILER_LANG['smtp_error'] = 'SMTP greška: ';
$PHPMAILER_LANG['variable_set'] = 'Nije moguće postaviti varijablu ili je vratiti nazad: '; $PHPMAILER_LANG['variable_set'] = 'Nije moguće postaviti varijablu ili je vratiti nazad: ';
$PHPMAILER_LANG['extension_missing'] = 'Nedostaje ekstenzija: '; $PHPMAILER_LANG['extension_missing'] = 'Nedostaje ekstenzija: ';

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Belarusian PHPMailer language file: refer to English translation for definitive list * Belarusian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Bulgarian PHPMailer language file: refer to English translation for definitive list * Bulgarian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Catalan PHPMailer language file: refer to English translation for definitive list * Catalan PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Chinese PHPMailer language file: refer to English translation for definitive list * Chinese PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Czech PHPMailer language file: refer to English translation for definitive list * Czech PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,10 +1,11 @@
<?php <?php
/** /**
* Danish PHPMailer language file: refer to English translation for definitive list * Danish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer
* @author John Sebastian <jms@iwb.dk> * @author John Sebastian <jms@iwb.dk>
* Rewrite and extension of the work by Mikael Stokkebro <info@stokkebro.dk> * Rewrite and extension of the work by Mikael Stokkebro <info@stokkebro.dk>
* *
*/ */
$PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Login mislykkedes.'; $PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Login mislykkedes.';

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* German PHPMailer language file: refer to English translation for definitive list * German PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Greek PHPMailer language file: refer to English translation for definitive list * Greek PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Esperanto PHPMailer language file: refer to English translation for definitive list * Esperanto PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Spanish PHPMailer language file: refer to English translation for definitive list * Spanish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Estonian PHPMailer language file: refer to English translation for definitive list * Estonian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Persian/Farsi PHPMailer language file: refer to English translation for definitive list * Persian/Farsi PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Finnish PHPMailer language file: refer to English translation for definitive list * Finnish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Faroese PHPMailer language file: refer to English translation for definitive list * Faroese PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* French PHPMailer language file: refer to English translation for definitive list * French PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Galician PHPMailer language file: refer to English translation for definitive list * Galician PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Hebrew PHPMailer language file: refer to English translation for definitive list * Hebrew PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Hindi PHPMailer language file: refer to English translation for definitive list * Hindi PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Croatian PHPMailer language file: refer to English translation for definitive list * Croatian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Hungarian PHPMailer language file: refer to English translation for definitive list * Hungarian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Armenian PHPMailer language file: refer to English translation for definitive list * Armenian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Indonesian PHPMailer language file: refer to English translation for definitive list * Indonesian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Italian PHPMailer language file: refer to English translation for definitive list * Italian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Japanese PHPMailer language file: refer to English translation for definitive list * Japanese PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Georgian PHPMailer language file: refer to English translation for definitive list * Georgian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Korean PHPMailer language file: refer to English translation for definitive list * Korean PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Lithuanian PHPMailer language file: refer to English translation for definitive list * Lithuanian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Latvian PHPMailer language file: refer to English translation for definitive list * Latvian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,9 +1,11 @@
<?php <?php
/** /**
* Malagasy PHPMailer language file: refer to English translation for definitive list * Malagasy PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer
* @author Hackinet <piyushjha8164@gmail.com> * @author Hackinet <piyushjha8164@gmail.com>
*/ */
$PHPMAILER_LANG['authenticate'] = 'Hadisoana SMTP: Tsy nahomby ny fanamarinana.'; $PHPMAILER_LANG['authenticate'] = 'Hadisoana SMTP: Tsy nahomby ny fanamarinana.';
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Tsy afaka mampifandray amin\'ny mpampiantrano SMTP.'; $PHPMAILER_LANG['connect_host'] = 'SMTP Error: Tsy afaka mampifandray amin\'ny mpampiantrano SMTP.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP diso: tsy voarakitra ny angona.'; $PHPMAILER_LANG['data_not_accepted'] = 'SMTP diso: tsy voarakitra ny angona.';

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Malaysian PHPMailer language file: refer to English translation for definitive list * Malaysian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Norwegian Bokmål PHPMailer language file: refer to English translation for definitive list * Norwegian Bokmål PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Dutch PHPMailer language file: refer to PHPMailer.php for definitive list. * Dutch PHPMailer language file: refer to PHPMailer.php for definitive list.
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Polish PHPMailer language file: refer to English translation for definitive list * Polish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer
@ -14,7 +15,7 @@ $PHPMAILER_LANG['file_access'] = 'Brak dostępu do pliku: ';
$PHPMAILER_LANG['file_open'] = 'Nie można otworzyć pliku: '; $PHPMAILER_LANG['file_open'] = 'Nie można otworzyć pliku: ';
$PHPMAILER_LANG['from_failed'] = 'Następujący adres Nadawcy jest nieprawidłowy: '; $PHPMAILER_LANG['from_failed'] = 'Następujący adres Nadawcy jest nieprawidłowy: ';
$PHPMAILER_LANG['instantiate'] = 'Nie można wywołać funkcji mail(). Sprawdź konfigurację serwera.'; $PHPMAILER_LANG['instantiate'] = 'Nie można wywołać funkcji mail(). Sprawdź konfigurację serwera.';
$PHPMAILER_LANG['invalid_address'] = 'Nie można wysłać wiadomości, '. $PHPMAILER_LANG['invalid_address'] = 'Nie można wysłać wiadomości, ' .
'następujący adres Odbiorcy jest nieprawidłowy: '; 'następujący adres Odbiorcy jest nieprawidłowy: ';
$PHPMAILER_LANG['provide_address'] = 'Należy podać prawidłowy adres email Odbiorcy.'; $PHPMAILER_LANG['provide_address'] = 'Należy podać prawidłowy adres email Odbiorcy.';
$PHPMAILER_LANG['mailer_not_supported'] = 'Wybrana metoda wysyłki wiadomości nie jest obsługiwana.'; $PHPMAILER_LANG['mailer_not_supported'] = 'Wybrana metoda wysyłki wiadomości nie jest obsługiwana.';

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Portuguese (European) PHPMailer language file: refer to English translation for definitive list * Portuguese (European) PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Brazilian Portuguese PHPMailer language file: refer to English translation for definitive list * Brazilian Portuguese PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Romanian PHPMailer language file: refer to English translation for definitive list * Romanian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Russian PHPMailer language file: refer to English translation for definitive list * Russian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Slovak PHPMailer language file: refer to English translation for definitive list * Slovak PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Slovene PHPMailer language file: refer to English translation for definitive list * Slovene PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Serbian PHPMailer language file: refer to English translation for definitive list * Serbian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Swedish PHPMailer language file: refer to English translation for definitive list * Swedish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Tagalog PHPMailer language file: refer to English translation for definitive list * Tagalog PHPMailer language file: refer to English translation for definitive list
* *

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Turkish PHPMailer language file: refer to English translation for definitive list * Turkish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Ukrainian PHPMailer language file: refer to English translation for definitive list * Ukrainian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Vietnamese (Tiếng Việt) PHPMailer language file: refer to English translation for definitive list. * Vietnamese (Tiếng Việt) PHPMailer language file: refer to English translation for definitive list.
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Traditional Chinese PHPMailer language file: refer to English translation for definitive list * Traditional Chinese PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Simplified Chinese PHPMailer language file: refer to English translation for definitive list * Simplified Chinese PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer * @package PHPMailer

38
phpcs.xml Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<config name="testVersion" value="5.5-"/>
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php,phps"/>
<arg name="parallel" value="10"/>
<!-- Show progress -->
<arg value="p"/>
<file>src</file>
<file>test</file>
<file>examples</file>
<file>language</file>
<rule ref="PSR12">
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses"/>
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
<exclude name="PSR1.Methods.CamelCapsMethodName"/>
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
</rule>
<rule ref="PHPCompatibility">
<exclude name="PHPCompatibility.Constants.NewConstants.stream_crypto_method_tlsv1_1_clientFound"/>
<exclude name="PHPCompatibility.Constants.NewConstants.stream_crypto_method_tlsv1_2_clientFound"/>
<exclude name="PHPCompatibility.Constants.RemovedConstants.intl_idna_variant_2003Deprecated"/>
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.random_bytesFound"/>
<exclude name="PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated"/>
<exclude name="PHPCompatibility.ParameterValues.NewIDNVariantDefault.NotSet"/>
</rule>
</ruleset>

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer Exception class. * PHPMailer Exception class.
* PHP Version 5.5. * PHP Version 5.5.

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer - PHP email creation and transport class. * PHPMailer - PHP email creation and transport class.
* PHP Version 5.5. * PHP Version 5.5.

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer - PHP email creation and transport class. * PHPMailer - PHP email creation and transport class.
* PHP Version 5.5. * PHP Version 5.5.
@ -1185,9 +1186,11 @@ class PHPMailer
//Use this built-in parser if it's available //Use this built-in parser if it's available
$list = imap_rfc822_parse_adrlist($addrstr, ''); $list = imap_rfc822_parse_adrlist($addrstr, '');
foreach ($list as $address) { foreach ($list as $address) {
if (('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress( if (
$address->mailbox . '@' . $address->host ('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress(
)) { $address->mailbox . '@' . $address->host
)
) {
$addresses[] = [ $addresses[] = [
'name' => (property_exists($address, 'personal') ? $address->personal : ''), 'name' => (property_exists($address, 'personal') ? $address->personal : ''),
'address' => $address->mailbox . '@' . $address->host, 'address' => $address->mailbox . '@' . $address->host,
@ -1241,7 +1244,8 @@ class PHPMailer
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
// Don't validate now addresses with IDN. Will be done in send(). // Don't validate now addresses with IDN. Will be done in send().
$pos = strrpos($address, '@'); $pos = strrpos($address, '@');
if ((false === $pos) if (
(false === $pos)
|| ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported())
&& !static::validateAddress($address)) && !static::validateAddress($address))
) { ) {
@ -1393,7 +1397,8 @@ class PHPMailer
{ {
// Verify we have required functions, CharSet, and at-sign. // Verify we have required functions, CharSet, and at-sign.
$pos = strrpos($address, '@'); $pos = strrpos($address, '@');
if (!empty($this->CharSet) && if (
!empty($this->CharSet) &&
false !== $pos && false !== $pos &&
static::idnSupported() static::idnSupported()
) { ) {
@ -1455,7 +1460,8 @@ class PHPMailer
*/ */
public function preSend() public function preSend()
{ {
if ('smtp' === $this->Mailer if (
'smtp' === $this->Mailer
|| ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0) || ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0)
) { ) {
//SMTP mandates RFC-compliant line endings //SMTP mandates RFC-compliant line endings
@ -1466,7 +1472,8 @@ class PHPMailer
static::setLE(PHP_EOL); static::setLE(PHP_EOL);
} }
//Check for buggy PHP versions that add a header with an incorrect line break //Check for buggy PHP versions that add a header with an incorrect line break
if ('mail' === $this->Mailer if (
'mail' === $this->Mailer
&& ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017) && ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017)
|| (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103)) || (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103))
&& ini_get('mail.add_x_header') === '1' && ini_get('mail.add_x_header') === '1'
@ -1553,7 +1560,8 @@ class PHPMailer
} }
// Sign with DKIM if enabled // Sign with DKIM if enabled
if (!empty($this->DKIM_domain) if (
!empty($this->DKIM_domain)
&& !empty($this->DKIM_selector) && !empty($this->DKIM_selector)
&& (!empty($this->DKIM_private_string) && (!empty($this->DKIM_private_string)
|| (!empty($this->DKIM_private) || (!empty($this->DKIM_private)
@ -1611,7 +1619,7 @@ class PHPMailer
} }
} catch (Exception $exc) { } catch (Exception $exc) {
if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) { if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) {
$this->smtp->reset(); $this->smtp->reset();
} }
$this->setError($exc->getMessage()); $this->setError($exc->getMessage());
$this->edebug($exc->getMessage()); $this->edebug($exc->getMessage());
@ -1717,7 +1725,8 @@ class PHPMailer
protected static function isShellSafe($string) protected static function isShellSafe($string)
{ {
// Future-proof // Future-proof
if (escapeshellcmd($string) !== $string if (
escapeshellcmd($string) !== $string
|| !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""])
) { ) {
return false; return false;
@ -1901,7 +1910,7 @@ class PHPMailer
$isSent = true; $isSent = true;
} }
$callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]]; $callbacks[] = ['issent' => $isSent, 'to' => $to[0]];
} }
} }
@ -1981,11 +1990,13 @@ class PHPMailer
foreach ($hosts as $hostentry) { foreach ($hosts as $hostentry) {
$hostinfo = []; $hostinfo = [];
if (!preg_match( if (
'/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', !preg_match(
trim($hostentry), '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/',
$hostinfo trim($hostentry),
)) { $hostinfo
)
) {
$this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry)); $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry));
// Not a valid host entry // Not a valid host entry
continue; continue;
@ -2054,12 +2065,14 @@ class PHPMailer
// We must resend EHLO after TLS negotiation // We must resend EHLO after TLS negotiation
$this->smtp->hello($hello); $this->smtp->hello($hello);
} }
if ($this->SMTPAuth && !$this->smtp->authenticate( if (
$this->Username, $this->SMTPAuth && !$this->smtp->authenticate(
$this->Password, $this->Username,
$this->AuthType, $this->Password,
$this->oauth $this->AuthType,
)) { $this->oauth
)
) {
throw new Exception($this->lang('authenticate')); throw new Exception($this->lang('authenticate'));
} }
@ -2426,7 +2439,8 @@ class PHPMailer
} }
// sendmail and mail() extract Bcc from the header before sending // sendmail and mail() extract Bcc from the header before sending
if (( if (
(
'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer 'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer
) )
&& count($this->bcc) > 0 && count($this->bcc) > 0
@ -3896,7 +3910,8 @@ class PHPMailer
public static function isValidHost($host) public static function isValidHost($host)
{ {
//Simple syntax limits //Simple syntax limits
if (empty($host) if (
empty($host)
|| !is_string($host) || !is_string($host)
|| strlen($host) > 256 || strlen($host) > 256
|| !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host) || !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host)
@ -4062,7 +4077,8 @@ class PHPMailer
); );
continue; continue;
} }
if (// Only process relative URLs if a basedir is provided (i.e. no absolute local paths) if (
// Only process relative URLs if a basedir is provided (i.e. no absolute local paths)
!empty($basedir) !empty($basedir)
// Ignore URLs containing parent dir traversal (..) // Ignore URLs containing parent dir traversal (..)
&& (strpos($url, '..') === false) && (strpos($url, '..') === false)
@ -4084,13 +4100,14 @@ class PHPMailer
if (strlen($directory) > 1 && '/' !== substr($directory, -1)) { if (strlen($directory) > 1 && '/' !== substr($directory, -1)) {
$directory .= '/'; $directory .= '/';
} }
if ($this->addEmbeddedImage( if (
$basedir . $directory . $filename, $this->addEmbeddedImage(
$cid, $basedir . $directory . $filename,
$filename, $cid,
static::ENCODING_BASE64, $filename,
static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)) static::ENCODING_BASE64,
) static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION))
)
) { ) {
$message = preg_replace( $message = preg_replace(
'/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer POP-Before-SMTP Authentication Class. * PHPMailer POP-Before-SMTP Authentication Class.
* PHP Version 5.5. * PHP Version 5.5.

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer RFC821 SMTP email transport class. * PHPMailer RFC821 SMTP email transport class.
* PHP Version 5.5. * PHP Version 5.5.
@ -539,11 +540,12 @@ class SMTP
return false; return false;
} }
// Send encoded username and password // Send encoded username and password
if (!$this->sendCommand( if (
'User & Password', !$this->sendCommand(
base64_encode("\0" . $username . "\0" . $password), 'User & Password',
235 base64_encode("\0" . $username . "\0" . $password),
) 235
)
) { ) {
return false; return false;
} }
@ -1086,8 +1088,10 @@ class SMTP
{ {
//If SMTP transcripts are left enabled, or debug output is posted online //If SMTP transcripts are left enabled, or debug output is posted online
//it can leak credentials, so hide credentials in all but lowest level //it can leak credentials, so hide credentials in all but lowest level
if (self::DEBUG_LOWLEVEL > $this->do_debug && if (
in_array($command, ['User & Password', 'Username', 'Password'], true)) { self::DEBUG_LOWLEVEL > $this->do_debug &&
in_array($command, ['User & Password', 'Username', 'Password'], true)
) {
$this->edebug('CLIENT -> SERVER: [credentials hidden]', self::DEBUG_CLIENT); $this->edebug('CLIENT -> SERVER: [credentials hidden]', self::DEBUG_CLIENT);
} else { } else {
$this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT); $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT);
@ -1207,7 +1211,8 @@ class SMTP
self::DEBUG_LOWLEVEL self::DEBUG_LOWLEVEL
); );
//stream_select returns false when the `select` system call is interrupted by an incoming signal, try the select again //stream_select returns false when the `select` system call is interrupted
//by an incoming signal, try the select again
if (stripos($message, 'interrupted system call') !== false) { if (stripos($message, 'interrupted system call') !== false) {
$this->edebug( $this->edebug(
'SMTP -> get_lines(): retrying stream_select', 'SMTP -> get_lines(): retrying stream_select',

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer - language file tests. * PHPMailer - language file tests.
* *

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer - language file tests. * PHPMailer - language file tests.
* *

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPMailer - PHP email transport unit tests. * PHPMailer - PHP email transport unit tests.
* PHP version 5.5. * PHP version 5.5.
@ -1218,10 +1219,11 @@ EOT;
$this->Mail->isHTML(true); $this->Mail->isHTML(true);
$this->Mail->CharSet = 'UTF-8'; $this->Mail->CharSet = 'UTF-8';
if (!$this->Mail->addAttachment( if (
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'), !$this->Mail->addAttachment(
'phpmailer_mini.png' realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
) 'phpmailer_mini.png'
)
) { ) {
self::assertTrue(false, $this->Mail->ErrorInfo); self::assertTrue(false, $this->Mail->ErrorInfo);
@ -1311,14 +1313,16 @@ EOT;
$this->Mail->Subject .= ': HTML + unnamed embedded image'; $this->Mail->Subject .= ': HTML + unnamed embedded image';
$this->Mail->isHTML(true); $this->Mail->isHTML(true);
if (!$this->Mail->addStringEmbeddedImage( if (
file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')), !$this->Mail->addStringEmbeddedImage(
hash('sha256', 'phpmailer_mini.png') . '@phpmailer.0', file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')),
'', //Intentionally empty name hash('sha256', 'phpmailer_mini.png') . '@phpmailer.0',
'base64', '', //Intentionally empty name
'', //Intentionally empty MIME type 'base64',
'inline' '', //Intentionally empty MIME type
)) { 'inline'
)
) {
self::assertTrue(false, $this->Mail->ErrorInfo); self::assertTrue(false, $this->Mail->ErrorInfo);
return; return;
@ -1337,20 +1341,22 @@ EOT;
$this->Mail->Subject .= ': HTML + multiple Attachment'; $this->Mail->Subject .= ': HTML + multiple Attachment';
$this->Mail->isHTML(true); $this->Mail->isHTML(true);
if (!$this->Mail->addAttachment( if (
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'), !$this->Mail->addAttachment(
'phpmailer_mini.png' realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
) 'phpmailer_mini.png'
)
) { ) {
self::assertTrue(false, $this->Mail->ErrorInfo); self::assertTrue(false, $this->Mail->ErrorInfo);
return; return;
} }
if (!$this->Mail->addAttachment( if (
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), !$this->Mail->addAttachment(
'phpmailer.png' realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
) 'phpmailer.png'
)
) { ) {
self::assertTrue(false, $this->Mail->ErrorInfo); self::assertTrue(false, $this->Mail->ErrorInfo);
@ -1372,13 +1378,14 @@ EOT;
$this->Mail->Subject .= ': Embedded Image'; $this->Mail->Subject .= ': Embedded Image';
$this->Mail->isHTML(true); $this->Mail->isHTML(true);
if (!$this->Mail->addEmbeddedImage( if (
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), !$this->Mail->addEmbeddedImage(
'my-attach', realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
'phpmailer.png', 'my-attach',
'base64', 'phpmailer.png',
'image/png' 'base64',
) 'image/png'
)
) { ) {
self::assertTrue(false, $this->Mail->ErrorInfo); self::assertTrue(false, $this->Mail->ErrorInfo);
@ -1420,13 +1427,14 @@ EOT;
$this->Mail->Subject .= ': Embedded Image + Attachment'; $this->Mail->Subject .= ': Embedded Image + Attachment';
$this->Mail->isHTML(true); $this->Mail->isHTML(true);
if (!$this->Mail->addEmbeddedImage( if (
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), !$this->Mail->addEmbeddedImage(
'my-attach', realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
'phpmailer.png', 'my-attach',
'base64', 'phpmailer.png',
'image/png' 'base64',
) 'image/png'
)
) { ) {
self::assertTrue(false, $this->Mail->ErrorInfo); self::assertTrue(false, $this->Mail->ErrorInfo);
@ -2805,7 +2813,8 @@ EOT;
// $this->Mail->smtpClose(); // $this->Mail->smtpClose();
// All these hosts are expected to fail // All these hosts are expected to fail
// $this->Mail->Host = 'xyz://bogus:25;tls://[bogus]:25;ssl://localhost:12345;tls://localhost:587;10.10.10.10:54321;localhost:12345;10.10.10.10'. $_REQUEST['mail_host'].' '; // $this->Mail->Host = 'xyz://bogus:25;tls://[bogus]:25;ssl://localhost:12345;
// tls://localhost:587;10.10.10.10:54321;localhost:12345;10.10.10.10'. $_REQUEST['mail_host'].' ';
// self::assertFalse($this->Mail->smtpConnect()); // self::assertFalse($this->Mail->smtpConnect());
// $this->Mail->smtpClose(); // $this->Mail->smtpClose();
@ -2836,7 +2845,7 @@ EOT;
$property->setValue($PHPMailer, true); $property->setValue($PHPMailer, true);
self::assertTrue($PHPMailer->getOAuth()); self::assertTrue($PHPMailer->getOAuth());
$options =[ $options = [
'provider' => 'dummyprovider', 'provider' => 'dummyprovider',
'userName' => 'dummyusername', 'userName' => 'dummyusername',
'clientSecret' => 'dummyclientsecret', 'clientSecret' => 'dummyclientsecret',

View File

@ -1,7 +1,9 @@
<?php <?php
/** /**
* PHPUnit bootstrap file. * PHPUnit bootstrap file.
*/ */
ini_set('sendmail_path', '/usr/sbin/sendmail -t -i '); ini_set('sendmail_path', '/usr/sbin/sendmail -t -i ');
if (file_exists('vendor/autoload.php')) { if (file_exists('vendor/autoload.php')) {
require_once 'vendor/autoload.php'; require_once 'vendor/autoload.php';