mirror of
https://github.com/PHPMailer/PHPMailer.git
synced 2024-09-19 17:42:14 +02:00
Switch from PHP CS fixer to phpcs and apply PSR12 reformatting
This commit is contained in:
parent
282f0fc0ce
commit
22e81749ae
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
11
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,6 +1,9 @@
|
||||
Before submitting your pull request, check whether your code adheres to PHPMailer
|
||||
coding standards by running the following command:
|
||||
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):
|
||||
|
||||
`./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
1
.gitignore
vendored
@ -6,4 +6,3 @@ build/
|
||||
vendor/
|
||||
*.pem
|
||||
composer.lock
|
||||
.php_cs.cache
|
||||
|
35
.php_cs
35
.php_cs
@ -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')
|
||||
)
|
||||
;
|
@ -1,6 +1,6 @@
|
||||
build:
|
||||
environment:
|
||||
php: '5.6.0'
|
||||
php: '7.4.0'
|
||||
|
||||
before_commands:
|
||||
- "composer install --prefer-source"
|
||||
@ -49,19 +49,6 @@ tools:
|
||||
- test
|
||||
- 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.
|
||||
php_loc:
|
||||
enabled: true
|
||||
|
18
.travis.yml
18
.travis.yml
@ -10,7 +10,6 @@ before_install:
|
||||
- sudo apt-get install -y -qq postfix
|
||||
|
||||
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
|
||||
- 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 cp test/fakesendmail.sh /var/qmail/bin/sendmail
|
||||
- sudo cp test/fakesendmail.sh /usr/sbin/sendmail
|
||||
- |
|
||||
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
|
||||
- echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini
|
||||
|
||||
script: ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist
|
||||
|
||||
@ -43,12 +37,8 @@ stages:
|
||||
jobs:
|
||||
include:
|
||||
- stage: coding-standard
|
||||
before_install:
|
||||
before_script:
|
||||
script: ./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix
|
||||
after_script:
|
||||
php: 5.6
|
||||
env: CS_CHECK=1
|
||||
script: ./vendor/bin/phpcs -s
|
||||
php: 7.4
|
||||
- stage: test
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
@ -57,10 +47,8 @@ jobs:
|
||||
- php: 7.4
|
||||
env: CODE_COVERAGE=1
|
||||
- php: nightly
|
||||
- php: hhvm
|
||||
dist: trusty
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
- php: hhvm
|
||||
|
@ -32,9 +32,12 @@
|
||||
"ext-hash": "*"
|
||||
},
|
||||
"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",
|
||||
"doctrine/annotations": "^1.2"
|
||||
"doctrine/annotations": "^1.2",
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"roave/security-advisories": "dev-latest"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log": "For optional PSR-3 debug logging",
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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!)
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -14,7 +15,7 @@ use PHPMailer\PHPMailer\PHPMailer;
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Usual setup
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||
$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
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
|
||||
try {
|
||||
$mail->isMail();
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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)) {
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
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
|
||||
$mail = new PHPMailer();
|
||||
@ -58,8 +60,9 @@ EOT;
|
||||
if (!$mail->send()) {
|
||||
//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.
|
||||
if ($isAjax)
|
||||
if ($isAjax) {
|
||||
http_response_code(500);
|
||||
}
|
||||
|
||||
$response = [
|
||||
"status" => false,
|
||||
@ -93,7 +96,9 @@ EOT;
|
||||
</head>
|
||||
<body>
|
||||
<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">
|
||||
<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>
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows how to handle a simple contact form safely.
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows how to make use of PHPMailer's exceptions for error handling.
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -17,7 +18,7 @@ require '../vendor/autoload.php';
|
||||
/**
|
||||
* Use PHPMailer as a base class and extend it
|
||||
*/
|
||||
class myPHPMailer extends PHPMailer
|
||||
class MyPHPMailer extends PHPMailer
|
||||
{
|
||||
/**
|
||||
* myPHPMailer constructor.
|
||||
@ -50,7 +51,7 @@ class myPHPMailer extends PHPMailer
|
||||
{
|
||||
$this->Subject = '[Yay for me!] ' . $this->Subject;
|
||||
$r = parent::send();
|
||||
echo 'I sent a message with subject '. $this->Subject;
|
||||
echo 'I sent a message with subject ' . $this->Subject;
|
||||
|
||||
return $r;
|
||||
}
|
||||
@ -67,5 +68,5 @@ try {
|
||||
$mail->send(); //no need to check for errors - the exception handler will do it
|
||||
} catch (Exception $e) {
|
||||
//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();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -13,7 +14,7 @@ use PHPMailer\PHPMailer\SMTP;
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
|
||||
//Tell PHPMailer to use SMTP
|
||||
$mail->isSMTP();
|
||||
@ -69,7 +70,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
|
||||
|
||||
//send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
//Section 2: IMAP
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\SMTP;
|
||||
use PHPMailer\PHPMailer\OAuth;
|
||||
|
||||
// Alias the League Google OAuth2 provider class
|
||||
use League\OAuth2\Client\Provider\Google;
|
||||
|
||||
@ -20,7 +20,7 @@ date_default_timezone_set('Etc/UTC');
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
|
||||
//Tell PHPMailer to use SMTP
|
||||
$mail->isSMTP();
|
||||
@ -100,7 +100,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
|
||||
|
||||
//send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows sending a message using PHP's mail() function.
|
||||
*/
|
||||
@ -9,7 +10,7 @@ use PHPMailer\PHPMailer\PHPMailer;
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
//Set who the message is to be sent from
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
//Set an alternative reply-to address
|
||||
@ -28,7 +29,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
|
||||
|
||||
//send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows how to send a message to a whole list of recipients efficiently.
|
||||
*/
|
||||
@ -57,7 +58,8 @@ foreach ($result as $row) {
|
||||
|
||||
try {
|
||||
$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
|
||||
mysqli_query(
|
||||
$mysql,
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer simple file upload and send example.
|
||||
*/
|
||||
@ -16,7 +17,7 @@ if (array_key_exists('userfile', $_FILES)) {
|
||||
// Upload handled successfully
|
||||
// Now create a message
|
||||
require '../vendor/autoload.php';
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||
$mail->Subject = 'PHPMailer file sender';
|
||||
@ -26,7 +27,7 @@ if (array_key_exists('userfile', $_FILES)) {
|
||||
$msg .= 'Failed to attach file ' . $_FILES['userfile']['name'];
|
||||
}
|
||||
if (!$mail->send()) {
|
||||
$msg .= 'Mailer Error: '. $mail->ErrorInfo;
|
||||
$msg .= 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
$msg .= 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer multiple files upload and send example
|
||||
*/
|
||||
@ -10,7 +11,7 @@ $msg = '';
|
||||
if (array_key_exists('userfile', $_FILES)) {
|
||||
require '../vendor/autoload.php';
|
||||
// Create a message
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
$mail->setFrom('from@example.com', 'First Last');
|
||||
$mail->addAddress('whoto@example.com', 'John Doe');
|
||||
$mail->Subject = 'PHPMailer file sender';
|
||||
@ -28,7 +29,7 @@ if (array_key_exists('userfile', $_FILES)) {
|
||||
}
|
||||
}
|
||||
if (!$mail->send()) {
|
||||
$msg .= 'Mailer Error: '. $mail->ErrorInfo;
|
||||
$msg .= 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
$msg .= 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows sending a message using a local sendmail binary.
|
||||
*/
|
||||
@ -9,7 +10,7 @@ use PHPMailer\PHPMailer\PHPMailer;
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
// Set PHPMailer to use the sendmail transport
|
||||
$mail->isSendmail();
|
||||
//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
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer simple contact form 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;
|
||||
}
|
||||
if (!$err) {
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
$mail->isSMTP();
|
||||
$mail->Host = 'localhost';
|
||||
$mail->Port = 25;
|
||||
@ -65,7 +66,7 @@ if (array_key_exists('to', $_POST)) {
|
||||
$mail->Subject = 'Contact form: ' . $subject;
|
||||
$mail->Body = "Contact form submission\n\n" . $query;
|
||||
if (!$mail->send()) {
|
||||
$msg .= 'Mailer Error: '. $mail->ErrorInfo;
|
||||
$msg .= 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
$msg .= 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This PHPMailer example shows S/MIME signing a message and then sending.
|
||||
*
|
||||
@ -53,7 +54,7 @@ use PHPMailer\PHPMailer\PHPMailer;
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
//Set who the message is to be sent from
|
||||
//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
|
||||
@ -85,7 +86,7 @@ $mail->sign(
|
||||
|
||||
//Send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows making an SMTP connection with authentication.
|
||||
*/
|
||||
@ -14,7 +15,7 @@ date_default_timezone_set('Etc/UTC');
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
//Tell PHPMailer to use SMTP
|
||||
$mail->isSMTP();
|
||||
//Enable SMTP debugging
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This uses the SMTP class alone to check that a connection can be made to an SMTP server,
|
||||
* authenticate, then disconnect
|
||||
@ -15,7 +16,7 @@ require '../vendor/autoload.php';
|
||||
date_default_timezone_set('Etc/UTC');
|
||||
|
||||
//Create a new SMTP instance
|
||||
$smtp = new SMTP;
|
||||
$smtp = new SMTP();
|
||||
|
||||
//Enable connection-level debug output
|
||||
$smtp->do_debug = SMTP::DEBUG_CONNECTION;
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SMTP low memory example.
|
||||
*/
|
||||
@ -122,7 +123,7 @@ class PHPMailerLowMemory extends PHPMailer
|
||||
public function getSMTPInstance()
|
||||
{
|
||||
if (!is_object($this->smtp)) {
|
||||
$this->smtp = new SMTPLowMemory;
|
||||
$this->smtp = new SMTPLowMemory();
|
||||
}
|
||||
|
||||
return $this->smtp;
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This example shows making an SMTP connection without using authentication.
|
||||
*/
|
||||
@ -14,7 +15,7 @@ date_default_timezone_set('Etc/UTC');
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
//Tell PHPMailer to use SMTP
|
||||
$mail->isSMTP();
|
||||
//Enable SMTP debugging
|
||||
@ -46,7 +47,7 @@ $mail->addAttachment('images/phpmailer_mini.png');
|
||||
|
||||
//send the message, check for errors
|
||||
if (!$mail->send()) {
|
||||
echo 'Mailer Error: '. $mail->ErrorInfo;
|
||||
echo 'Mailer Error: ' . $mail->ErrorInfo;
|
||||
} else {
|
||||
echo 'Message sent!';
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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';
|
||||
|
||||
//Create a new PHPMailer instance
|
||||
$mail = new PHPMailer;
|
||||
$mail = new PHPMailer();
|
||||
|
||||
//Tell PHPMailer to use SMTP
|
||||
$mail->isSMTP();
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Afrikaans PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Arabic PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Azerbaijani PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Bosnian PHPMailer language file: refer to English translation for definitive list
|
||||
* @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_error'] = 'SMTP greška: ';
|
||||
$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: ';
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Belarusian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Bulgarian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Catalan PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chinese PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Czech PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Danish PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
* @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.';
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* German PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Greek PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Esperanto PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Spanish PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Estonian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Persian/Farsi PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Finnish PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Faroese PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* French PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Galician PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Hebrew PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Hindi PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Croatian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Hungarian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Armenian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Indonesian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Italian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Japanese PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Georgian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Korean PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Lithuanian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Latvian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Malagasy PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
* @author Hackinet <piyushjha8164@gmail.com>
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG['authenticate'] = 'Hadisoana SMTP: Tsy nahomby ny fanamarinana.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Tsy afaka mampifandray amin\'ny mpampiantrano SMTP.';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP diso: tsy voarakitra ny angona.';
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Malaysian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Norwegian Bokmål PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dutch PHPMailer language file: refer to PHPMailer.php for definitive list.
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Polish PHPMailer language file: refer to English translation for definitive list
|
||||
* @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['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['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: ';
|
||||
$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.';
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Portuguese (European) PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Brazilian Portuguese PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Romanian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Russian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slovak PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Slovene PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Serbian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Swedish PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tagalog PHPMailer language file: refer to English translation for definitive list
|
||||
*
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Turkish PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Ukrainian PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Vietnamese (Tiếng Việt) PHPMailer language file: refer to English translation for definitive list.
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Traditional Chinese PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Simplified Chinese PHPMailer language file: refer to English translation for definitive list
|
||||
* @package PHPMailer
|
||||
|
38
phpcs.xml
Normal file
38
phpcs.xml
Normal 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>
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer Exception class.
|
||||
* PHP Version 5.5.
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.5.
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer - PHP email creation and transport class.
|
||||
* PHP Version 5.5.
|
||||
@ -1185,9 +1186,11 @@ class PHPMailer
|
||||
//Use this built-in parser if it's available
|
||||
$list = imap_rfc822_parse_adrlist($addrstr, '');
|
||||
foreach ($list as $address) {
|
||||
if (('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress(
|
||||
$address->mailbox . '@' . $address->host
|
||||
)) {
|
||||
if (
|
||||
('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress(
|
||||
$address->mailbox . '@' . $address->host
|
||||
)
|
||||
) {
|
||||
$addresses[] = [
|
||||
'name' => (property_exists($address, 'personal') ? $address->personal : ''),
|
||||
'address' => $address->mailbox . '@' . $address->host,
|
||||
@ -1241,7 +1244,8 @@ class PHPMailer
|
||||
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
|
||||
// Don't validate now addresses with IDN. Will be done in send().
|
||||
$pos = strrpos($address, '@');
|
||||
if ((false === $pos)
|
||||
if (
|
||||
(false === $pos)
|
||||
|| ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported())
|
||||
&& !static::validateAddress($address))
|
||||
) {
|
||||
@ -1393,7 +1397,8 @@ class PHPMailer
|
||||
{
|
||||
// Verify we have required functions, CharSet, and at-sign.
|
||||
$pos = strrpos($address, '@');
|
||||
if (!empty($this->CharSet) &&
|
||||
if (
|
||||
!empty($this->CharSet) &&
|
||||
false !== $pos &&
|
||||
static::idnSupported()
|
||||
) {
|
||||
@ -1455,7 +1460,8 @@ class PHPMailer
|
||||
*/
|
||||
public function preSend()
|
||||
{
|
||||
if ('smtp' === $this->Mailer
|
||||
if (
|
||||
'smtp' === $this->Mailer
|
||||
|| ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0)
|
||||
) {
|
||||
//SMTP mandates RFC-compliant line endings
|
||||
@ -1466,7 +1472,8 @@ class PHPMailer
|
||||
static::setLE(PHP_EOL);
|
||||
}
|
||||
//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 >= 70100 && PHP_VERSION_ID < 70103))
|
||||
&& ini_get('mail.add_x_header') === '1'
|
||||
@ -1553,7 +1560,8 @@ class PHPMailer
|
||||
}
|
||||
|
||||
// Sign with DKIM if enabled
|
||||
if (!empty($this->DKIM_domain)
|
||||
if (
|
||||
!empty($this->DKIM_domain)
|
||||
&& !empty($this->DKIM_selector)
|
||||
&& (!empty($this->DKIM_private_string)
|
||||
|| (!empty($this->DKIM_private)
|
||||
@ -1611,7 +1619,7 @@ class PHPMailer
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) {
|
||||
$this->smtp->reset();
|
||||
$this->smtp->reset();
|
||||
}
|
||||
$this->setError($exc->getMessage());
|
||||
$this->edebug($exc->getMessage());
|
||||
@ -1717,7 +1725,8 @@ class PHPMailer
|
||||
protected static function isShellSafe($string)
|
||||
{
|
||||
// Future-proof
|
||||
if (escapeshellcmd($string) !== $string
|
||||
if (
|
||||
escapeshellcmd($string) !== $string
|
||||
|| !in_array(escapeshellarg($string), ["'$string'", "\"$string\""])
|
||||
) {
|
||||
return false;
|
||||
@ -1901,7 +1910,7 @@ class PHPMailer
|
||||
$isSent = true;
|
||||
}
|
||||
|
||||
$callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]];
|
||||
$callbacks[] = ['issent' => $isSent, 'to' => $to[0]];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1981,11 +1990,13 @@ class PHPMailer
|
||||
|
||||
foreach ($hosts as $hostentry) {
|
||||
$hostinfo = [];
|
||||
if (!preg_match(
|
||||
'/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/',
|
||||
trim($hostentry),
|
||||
$hostinfo
|
||||
)) {
|
||||
if (
|
||||
!preg_match(
|
||||
'/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/',
|
||||
trim($hostentry),
|
||||
$hostinfo
|
||||
)
|
||||
) {
|
||||
$this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry));
|
||||
// Not a valid host entry
|
||||
continue;
|
||||
@ -2054,12 +2065,14 @@ class PHPMailer
|
||||
// We must resend EHLO after TLS negotiation
|
||||
$this->smtp->hello($hello);
|
||||
}
|
||||
if ($this->SMTPAuth && !$this->smtp->authenticate(
|
||||
$this->Username,
|
||||
$this->Password,
|
||||
$this->AuthType,
|
||||
$this->oauth
|
||||
)) {
|
||||
if (
|
||||
$this->SMTPAuth && !$this->smtp->authenticate(
|
||||
$this->Username,
|
||||
$this->Password,
|
||||
$this->AuthType,
|
||||
$this->oauth
|
||||
)
|
||||
) {
|
||||
throw new Exception($this->lang('authenticate'));
|
||||
}
|
||||
|
||||
@ -2426,7 +2439,8 @@ class PHPMailer
|
||||
}
|
||||
|
||||
// sendmail and mail() extract Bcc from the header before sending
|
||||
if ((
|
||||
if (
|
||||
(
|
||||
'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer
|
||||
)
|
||||
&& count($this->bcc) > 0
|
||||
@ -3896,7 +3910,8 @@ class PHPMailer
|
||||
public static function isValidHost($host)
|
||||
{
|
||||
//Simple syntax limits
|
||||
if (empty($host)
|
||||
if (
|
||||
empty($host)
|
||||
|| !is_string($host)
|
||||
|| strlen($host) > 256
|
||||
|| !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host)
|
||||
@ -4062,7 +4077,8 @@ class PHPMailer
|
||||
);
|
||||
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)
|
||||
// Ignore URLs containing parent dir traversal (..)
|
||||
&& (strpos($url, '..') === false)
|
||||
@ -4084,13 +4100,14 @@ class PHPMailer
|
||||
if (strlen($directory) > 1 && '/' !== substr($directory, -1)) {
|
||||
$directory .= '/';
|
||||
}
|
||||
if ($this->addEmbeddedImage(
|
||||
$basedir . $directory . $filename,
|
||||
$cid,
|
||||
$filename,
|
||||
static::ENCODING_BASE64,
|
||||
static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION))
|
||||
)
|
||||
if (
|
||||
$this->addEmbeddedImage(
|
||||
$basedir . $directory . $filename,
|
||||
$cid,
|
||||
$filename,
|
||||
static::ENCODING_BASE64,
|
||||
static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION))
|
||||
)
|
||||
) {
|
||||
$message = preg_replace(
|
||||
'/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer POP-Before-SMTP Authentication Class.
|
||||
* PHP Version 5.5.
|
||||
|
21
src/SMTP.php
21
src/SMTP.php
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer RFC821 SMTP email transport class.
|
||||
* PHP Version 5.5.
|
||||
@ -539,11 +540,12 @@ class SMTP
|
||||
return false;
|
||||
}
|
||||
// Send encoded username and password
|
||||
if (!$this->sendCommand(
|
||||
'User & Password',
|
||||
base64_encode("\0" . $username . "\0" . $password),
|
||||
235
|
||||
)
|
||||
if (
|
||||
!$this->sendCommand(
|
||||
'User & Password',
|
||||
base64_encode("\0" . $username . "\0" . $password),
|
||||
235
|
||||
)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@ -1086,8 +1088,10 @@ class SMTP
|
||||
{
|
||||
//If SMTP transcripts are left enabled, or debug output is posted online
|
||||
//it can leak credentials, so hide credentials in all but lowest level
|
||||
if (self::DEBUG_LOWLEVEL > $this->do_debug &&
|
||||
in_array($command, ['User & Password', 'Username', 'Password'], true)) {
|
||||
if (
|
||||
self::DEBUG_LOWLEVEL > $this->do_debug &&
|
||||
in_array($command, ['User & Password', 'Username', 'Password'], true)
|
||||
) {
|
||||
$this->edebug('CLIENT -> SERVER: [credentials hidden]', self::DEBUG_CLIENT);
|
||||
} else {
|
||||
$this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT);
|
||||
@ -1207,7 +1211,8 @@ class SMTP
|
||||
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) {
|
||||
$this->edebug(
|
||||
'SMTP -> get_lines(): retrying stream_select',
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer - language file tests.
|
||||
*
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer - language file tests.
|
||||
*
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPMailer - PHP email transport unit tests.
|
||||
* PHP version 5.5.
|
||||
@ -1218,10 +1219,11 @@ EOT;
|
||||
$this->Mail->isHTML(true);
|
||||
$this->Mail->CharSet = 'UTF-8';
|
||||
|
||||
if (!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
if (
|
||||
!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
) {
|
||||
self::assertTrue(false, $this->Mail->ErrorInfo);
|
||||
|
||||
@ -1311,14 +1313,16 @@ EOT;
|
||||
$this->Mail->Subject .= ': HTML + unnamed embedded image';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addStringEmbeddedImage(
|
||||
file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')),
|
||||
hash('sha256', 'phpmailer_mini.png') . '@phpmailer.0',
|
||||
'', //Intentionally empty name
|
||||
'base64',
|
||||
'', //Intentionally empty MIME type
|
||||
'inline'
|
||||
)) {
|
||||
if (
|
||||
!$this->Mail->addStringEmbeddedImage(
|
||||
file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')),
|
||||
hash('sha256', 'phpmailer_mini.png') . '@phpmailer.0',
|
||||
'', //Intentionally empty name
|
||||
'base64',
|
||||
'', //Intentionally empty MIME type
|
||||
'inline'
|
||||
)
|
||||
) {
|
||||
self::assertTrue(false, $this->Mail->ErrorInfo);
|
||||
|
||||
return;
|
||||
@ -1337,20 +1341,22 @@ EOT;
|
||||
$this->Mail->Subject .= ': HTML + multiple Attachment';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
if (
|
||||
!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'),
|
||||
'phpmailer_mini.png'
|
||||
)
|
||||
) {
|
||||
self::assertTrue(false, $this->Mail->ErrorInfo);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'phpmailer.png'
|
||||
)
|
||||
if (
|
||||
!$this->Mail->addAttachment(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'phpmailer.png'
|
||||
)
|
||||
) {
|
||||
self::assertTrue(false, $this->Mail->ErrorInfo);
|
||||
|
||||
@ -1372,13 +1378,14 @@ EOT;
|
||||
$this->Mail->Subject .= ': Embedded Image';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
'image/png'
|
||||
)
|
||||
if (
|
||||
!$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
'image/png'
|
||||
)
|
||||
) {
|
||||
self::assertTrue(false, $this->Mail->ErrorInfo);
|
||||
|
||||
@ -1420,13 +1427,14 @@ EOT;
|
||||
$this->Mail->Subject .= ': Embedded Image + Attachment';
|
||||
$this->Mail->isHTML(true);
|
||||
|
||||
if (!$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
'image/png'
|
||||
)
|
||||
if (
|
||||
!$this->Mail->addEmbeddedImage(
|
||||
realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'),
|
||||
'my-attach',
|
||||
'phpmailer.png',
|
||||
'base64',
|
||||
'image/png'
|
||||
)
|
||||
) {
|
||||
self::assertTrue(false, $this->Mail->ErrorInfo);
|
||||
|
||||
@ -2805,7 +2813,8 @@ EOT;
|
||||
// $this->Mail->smtpClose();
|
||||
|
||||
// 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());
|
||||
// $this->Mail->smtpClose();
|
||||
|
||||
@ -2836,7 +2845,7 @@ EOT;
|
||||
$property->setValue($PHPMailer, true);
|
||||
self::assertTrue($PHPMailer->getOAuth());
|
||||
|
||||
$options =[
|
||||
$options = [
|
||||
'provider' => 'dummyprovider',
|
||||
'userName' => 'dummyusername',
|
||||
'clientSecret' => 'dummyclientsecret',
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPUnit bootstrap file.
|
||||
*/
|
||||
|
||||
ini_set('sendmail_path', '/usr/sbin/sendmail -t -i ');
|
||||
if (file_exists('vendor/autoload.php')) {
|
||||
require_once 'vendor/autoload.php';
|
||||
|
Loading…
Reference in New Issue
Block a user