Lazy images and update PHPMailer

This commit is contained in:
Miraty 2021-04-05 16:29:11 +02:00
parent 691069d49c
commit ab62b79701
72 changed files with 1509 additions and 935 deletions

4
.gitignore vendored
View File

@ -2,5 +2,7 @@
*.jpg
*.PNG
*.JPG
mdp
mdp.php
.directory
400
800

View File

@ -1,10 +0,0 @@
é
#`{\`[^\{#`^[@#~[→đðßŋn€↓¶
gdsfgsdfg
gsdfg
dsfg
gdsf

View File

@ -13,7 +13,7 @@
<br>
<textarea name="message" rows="10" style="width: 85%;" title="10 000 caractères maximum" placeholder="Bonjour," maxlength="10000" type="text"></textarea>
<br>
<label for="captcha">Combien font cinq et trois ?</label>
<label for="captcha">Combien font cinq plus trois ?</label>
<br>
<input id="captcha" required="" type="text" name="captcha" />
<br>
@ -38,13 +38,14 @@ if (isset($_POST['message'])) {
$mail = new PHPMailer(true);
try {
require "mdp.php";
//Server settings
$mail->SMTPDebug = 0; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'yuno.antopie.org'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'send@antopie.org'; // SMTP username
$mail->Password = rtrim(file_get_contents("mdp")); // SMTP password
$mail->Password = $mdp; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
@ -57,31 +58,24 @@ if (isset($_POST['message'])) {
$mail->CharSet = 'UTF-8';
$mail->isHTML(false);
$mail->Subject = "Message depuis le site Web de Super·F·lux";
$mail->Body = substr($_POST['message'], 0, 20000);
$mail->Body = htmlspecialchars(substr($_POST['message'], 0, 20000));
$mail->send();
echo "Le message a bien été envoyé !";
} catch (Exception $e) {
echo "Le message n'a pas put être envoyé. Mailer Error: {$mail->ErrorInfo}";
echo "Le message n'a pas pu être envoyé. Mailer Error: {$mail->ErrorInfo}";
}
} else {
echo "Erreur : Captcha invalide !";
}
} else {
echo "ERREUR : Le message fait plus de 10 000 caractères !";
}
}
?>
<?php include "fin.inc.php"; ?>

View File

@ -3,9 +3,8 @@
<br>
Images créées par Cécile Chevallier et diffusées sous <a href="CC_BY-SA_4.0_FR.html">CC BY-SA 4.0</a>.
<br>
<a href="https://code.antopie.org/miraty/superflux">Site Web</a> créé par <a href="https://www.antopie.org">Miraty</a> sous <a href="LICENSE.html">AGPLv3+</a>.
<a href="https://code.antopie.org/miraty/superflux">Site Web</a> sous <a href="LICENSE.html">AGPLv3+</a>.
</footer>
</body>
</html>

View File

@ -75,7 +75,7 @@
?>">
<img src="<?php echo $cheminComplet . "/" . $listeElements->getFilename() . "/400/index.jpg"; ?>">
<img loading="lazy" src="<?php echo $cheminComplet . "/" . $listeElements->getFilename() . "/400/index.jpg"; ?>">
<div class="nomElementDossier"><?php echo $listeElements->getFilename(); ?></div>
</a>
</div>
@ -96,7 +96,7 @@
?>">
<a href="<?php echo $cheminComplet . "/" . $listeElements->getFilename(); ?>" data-title="Image créée par Cécile Chevallier et diffusée sous CC BY-SA 4.0." data-lightbox="<?php echo $listeElements->getFilename(); ?>">
<img src="<?php
<img loading="lazy" src="<?php
if ($dimensions[0] > $dimensions[1]) {
echo $cheminComplet . "/800/" . $listeElements->getFilename();
@ -109,7 +109,7 @@
</div>
<?php
} else {
echo $cheminComplet . $listeElements->getFilename();
echo $adresseImage;
echo "ERREUR PHP : L'élément n'est ni un fichier ni un dossier !";
}
@ -183,7 +183,6 @@
$j++;
}
?>
<form method="POST" action="index.php?chemin=<?= $_GET['chemin'] ?>">
@ -196,7 +195,7 @@
<br>
<textarea id="commentaire" required="" title="1 000 caractères maximum" maxlength="1000" name="commentaire" style="width:85%;" placeholder="Votre message" rows="6"></textarea>
<br>
<label for="captcha">Combien font cinq et trois ?</label>
<label for="captcha">Combien font cinq plus trois ?</label>
<br>
<input id="captcha" required="" type="text" name="captcha" />
<br>

0
phpmailer/COMMITMENT Executable file → Normal file
View File

0
phpmailer/LICENSE Executable file → Normal file
View File

142
phpmailer/README.md Executable file → Normal file
View File

@ -1,46 +1,45 @@
![PHPMailer](https://raw.github.com/PHPMailer/PHPMailer/master/examples/images/phpmailer.png)
# PHPMailer - A full-featured email creation and transfer class for PHP
# PHPMailer A full-featured email creation and transfer class for PHP
Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/quality-score.png?s=3758e21d279becdf847a557a56a3ed16dfec9d5d)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
[![Code Coverage](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/coverage.png?s=3fe6ca5fe8cd2cdf96285756e42932f7ca256962)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/)
[![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions) [![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![API Docs](https://github.com/phpmailer/phpmailer/workflows/Docs/badge.svg)](https://phpmailer.github.io/PHPMailer/)
[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) [![Latest Unstable Version](https://poser.pugx.org/phpmailer/phpmailer/v/unstable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer)
## Class Features
## Features
- Probably the world's most popular code for sending email from PHP!
- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more
- Integrated SMTP support - send without a local mail server
- Integrated SMTP support send without a local mail server
- Send emails with multiple To, CC, BCC and Reply-to addresses
- Multipart/alternative emails for mail clients that do not read HTML email
- Add attachments, including inline
- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings
- SMTP authentication with LOGIN, PLAIN, CRAM-MD5 and XOAUTH2 mechanisms over SSL and SMTP+STARTTLS transports
- SMTP authentication with LOGIN, PLAIN, CRAM-MD5, and XOAUTH2 mechanisms over SMTPS and SMTP+STARTTLS transports
- Validates email addresses automatically
- Protect against header injection attacks
- Protects against header injection attacks
- Error messages in over 50 languages!
- DKIM and S/MIME signing support
- Compatible with PHP 5.5 and later
- Compatible with PHP 5.5 and later, including PHP 8.0
- Namespaced to prevent name clashes
- Much more!
## Why you might need it
Many PHP developers utilize email in their code. The only PHP function that supports this is the `mail()` function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments.
Many PHP developers need to send email from their code. The only PHP function that supports this directly is [`mail()`](https://www.php.net/manual/en/function.mail.php). However, it does not provide any assistance for making use of popular features such as encryption, authentication, HTML messages, and attachments.
Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong!
*Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try [SwiftMailer](https://swiftmailer.symfony.com/), [Zend/Mail](https://zendframework.github.io/zend-mail/), [eZcomponents](https://github.com/zetacomponents/Mail) etc.
Formatting email correctly is surprisingly difficult. There are myriad overlapping (and conflicting) standards, requiring tight adherence to horribly complicated formatting and encoding rules the vast majority of code that you'll find online that uses the `mail()` function directly is just plain wrong, if not unsafe!
The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server.
The PHP `mail()` function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD, and macOS platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP client allows email sending on all platforms without needing a local mail server. Be aware though, that the `mail()` function should be avoided when possible; it's both faster and [safer](https://exploitbox.io/paper/Pwning-PHP-Mail-Function-For-Fun-And-RCE.html) to use SMTP to localhost.
*Please* don't be tempted to do it yourself if you don't use PHPMailer, there are many other excellent libraries that
you should look at before rolling your own. Try [SwiftMailer](https://swiftmailer.symfony.com/)
, [Laminas/Mail](https://docs.laminas.dev/laminas-mail/), [ZetaComponents](https://github.com/zetacomponents/Mail) etc.
## License
This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read LICENSE for information on the software availability and distribution.
This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license, along with the [GPL Cooperation Commitment](https://gplcc.github.io/gplcc/). Please read [LICENSE](https://github.com/PHPMailer/PHPMailer/blob/master/LICENSE) for information on the software availability and distribution.
## Installation & loading
PHPMailer is available on [Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install PHPMailer. Just add this line to your `composer.json` file:
```json
"phpmailer/phpmailer": "~6.0"
"phpmailer/phpmailer": "^6.2"
```
or run
@ -53,7 +52,8 @@ Note that the `vendor` folder and the `vendor/autoload.php` script are generated
If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the `league/oauth2-client` package in your `composer.json`.
Alternatively, if you're not using Composer, copy the contents of the PHPMailer folder into one of the `include_path` directories specified in your PHP configuration and load each class file manually:
Alternatively, if you're not using Composer, you
can [download PHPMailer as a zip file](https://github.com/PHPMailer/PHPMailer/archive/master.zip), (note that docs and examples are not included in the zip file), then copy the contents of the PHPMailer folder into one of the `include_path` directories specified in your PHP configuration and load each class file manually:
```php
<?php
@ -65,61 +65,58 @@ require 'path/to/PHPMailer/src/PHPMailer.php';
require 'path/to/PHPMailer/src/SMTP.php';
```
If you're not using the `SMTP` class explicitly (you're probably not), you don't need a `use` line for the SMTP class.
If you don't speak git or just want a tarball, click the 'zip' button on the right of the project page in GitHub, though note that docs and examples are not included in the tarball.
If you're not using the `SMTP` class explicitly (you're probably not), you don't need a `use` line for the SMTP class. Even if you're not using exceptions, you do still need to load the `Exception` class as it is used internally.
## Legacy versions
PHPMailer 5.2 (which is compatible with PHP 5.0 - 7.0) is no longer being supported for feature updates, and will only be receiving security updates from now on. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable), and future versions of 5.2 will be tagged with 5.2.x version numbers, so existing Composer configs should remain working. If you're using PHP 5.5 or later, we recommend you make the necessary changes to switch to the 6.0 release.
PHPMailer 5.2 (which is compatible with PHP 5.0 — 7.0) is no longer supported, even for security updates. You will find the latest version of 5.2 in the [5.2-stable branch](https://github.com/PHPMailer/PHPMailer/tree/5.2-stable). If you're using PHP 5.5 or later (which you should be), switch to the 6.x releases.
The 5.2 branch will not receive security updates after December 31st 2018.
## Upgrading from 5.2
### Upgrading from 5.2
The biggest changes are that source files are now in the `src/` folder, and PHPMailer now declares the namespace `PHPMailer\PHPMailer`. This has several important effects [read the upgrade guide](https://github.com/PHPMailer/PHPMailer/tree/master/UPGRADING.md) for more details.
### Minimal installation
While installing the entire package manually or with Composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP, you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer!
While installing the entire package manually or with Composer is simple, convenient, and reliable, you may want to include only vital files in your project. At the very least you will need [src/PHPMailer.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/PHPMailer.php). If you're using SMTP, you'll need [src/SMTP.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/SMTP.php), and if you're using POP-before SMTP (*very* unlikely!), you'll need [src/POP3.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/POP3.php). You can skip the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder if you're not showing errors to users and can make do with English-only errors. If you're using XOAUTH2 you will need [src/OAuth.php](https://github.com/PHPMailer/PHPMailer/tree/master/src/OAuth.php) as well as the Composer dependencies for the services you wish to authenticate with. Really, it's much easier to use Composer!
## A Simple Example
```php
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
//Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
//Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.example.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'user@example.com'; //SMTP username
$mail->Password = 'secret'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
$mail->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
//Recipients
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen@example.com'); // Name is optional
$mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient
$mail->addAddress('ellen@example.com'); //Name is optional
$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');
// Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
@ -131,59 +128,53 @@ try {
}
```
You'll find plenty more to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder.
You'll find plenty to play with in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder, which covers many common scenarios including sending through gmail, building contact forms, sending to mailing lists, and more.
If you are re-using the instance (e.g. when sending to a mailing list), you may need to clear the recipient list to avoid sending duplicate messages. See [the mailing list example](https://github.com/PHPMailer/PHPMailer/blob/master/examples/mailing_list.phps) for further guidance.
That's it. You should now be ready to use PHPMailer!
## Localization
PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder you'll find numerous (48 at the time of writing!) translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
PHPMailer defaults to English, but in the [language](https://github.com/PHPMailer/PHPMailer/tree/master/language/) folder you'll find many translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this:
```php
// To load the French version
//To load the French version
$mail->setLanguage('fr', '/optional/path/to/language/directory/');
```
We welcome corrections and new languages - if you're looking for corrections to do, run the [PHPMailerLangTest.php](https://github.com/PHPMailer/PHPMailer/tree/master/test/PHPMailerLangTest.php) script in the tests folder and it will show any missing translations.
We welcome corrections and new languages if you're looking for corrections, run the [PHPMailerLangTest.php](https://github.com/PHPMailer/PHPMailer/tree/master/test/PHPMailerLangTest.php) script in the tests folder and it will show any missing translations.
## Documentation
Start reading at the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, this should be the first place you look as it's the most frequently updated.
Start reading at the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, head for [the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting) as it's frequently updated.
Examples of how to use PHPMailer for common scenarios can be found in the [examples](https://github.com/PHPMailer/PHPMailer/tree/master/examples) folder. If you're looking for a good starting point, we recommend you start with [the Gmail example](https://github.com/PHPMailer/PHPMailer/tree/master/examples/gmail.phps).
Note that in order to reduce PHPMailer's deployed code footprint, the examples are no longer included if you load PHPMailer via Composer or via [GitHub's zip file download](https://github.com/PHPMailer/PHPMailer/archive/master.zip), so you'll need to either clone the git repository or use the above links to get to the examples directly.
To reduce PHPMailer's deployed code footprint, examples are not included if you load PHPMailer via Composer or via [GitHub's zip file download](https://github.com/PHPMailer/PHPMailer/archive/master.zip), so you'll need to either clone the git repository or use the above links to get to the examples directly.
Complete generated API documentation is [available online](http://phpmailer.github.io/PHPMailer/).
Complete generated API documentation is [available online](https://phpmailer.github.io/PHPMailer/).
You can generate complete API-level documentation by running `phpdoc` in the top-level folder, and documentation will appear in the `docs` folder, though you'll need to have [PHPDocumentor](http://www.phpdoc.org) installed. You may find [the unit tests](https://github.com/PHPMailer/PHPMailer/tree/master/test/phpmailerTest.php) a good source of how to do various operations such as encryption.
You can generate complete API-level documentation by running `phpdoc` in the top-level folder, and documentation will appear in the `docs` folder, though you'll need to have [PHPDocumentor](http://www.phpdoc.org) installed. You may find [the unit tests](https://github.com/PHPMailer/PHPMailer/blob/master/test/PHPMailerTest.php) a good reference for how to do various operations such as encryption.
If the documentation doesn't cover what you need, search the [many questions on Stack Overflow](http://stackoverflow.com/questions/tagged/phpmailer), and before you ask a question about "SMTP Error: Could not connect to SMTP host.", [read the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting).
## Tests
There is a PHPUnit test script in the [test](https://github.com/PHPMailer/PHPMailer/tree/master/test/) folder. PHPMailer uses PHPUnit 4.8 - we would use 5.x but we need to run on PHP 5.5.
[PHPMailer tests](https://github.com/PHPMailer/PHPMailer/tree/master/test/) use PHPUnit 9, with [a polyfill](https://github.com/Yoast/PHPUnit-Polyfills) to let 9-style tests run on older PHPUnit and PHP versions.
Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer)
[![Test status](https://github.com/PHPMailer/PHPMailer/workflows/Tests/badge.svg)](https://github.com/PHPMailer/PHPMailer/actions)
If this isn't passing, is there something you can do to help?
## Security
Please disclose any vulnerabilities found responsibly - report any security problems found to the maintainers privately.
Please disclose any vulnerabilities found responsibly report security issues to the maintainers privately.
PHPMailer versions prior to 5.2.22 (released January 9th 2017) have a local file disclosure vulnerability, [CVE-2017-5223](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5223). If content passed into `msgHTML()` is sourced from unfiltered user input, relative paths can map to absolute local file paths and added as attachments. Also note that `addAttachment` (just like `file_get_contents`, `passthru`, `unlink`, etc) should not be passed user-sourced params either! Reported by Yongxiang Li of Asiasecurity.
PHPMailer versions prior to 5.2.20 (released December 28th 2016) are vulnerable to [CVE-2016-10045](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10045) a remote code execution vulnerability, responsibly reported by [Dawid Golunski](https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10045-Vuln-Patch-Bypass.html), and patched by Paul Buonopane (@Zenexer).
PHPMailer versions prior to 5.2.18 (released December 2016) are vulnerable to [CVE-2016-10033](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-10033) a critical remote code execution vulnerability, responsibly reported by [Dawid Golunski](http://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html).
See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) for more detail on security issues.
See [SECURITY](https://github.com/PHPMailer/PHPMailer/tree/master/SECURITY.md) and [PHPMailer's security advisories on GitHub](https://github.com/PHPMailer/PHPMailer/security).
## Contributing
Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues).
We're particularly interested in fixing edge-cases, expanding test coverage and updating translations.
If you found a mistake in the docs, or want to add something, go ahead and amend the wiki - anyone can edit it.
If you found a mistake in the docs, or want to add something, go ahead and amend the wiki anyone can edit it.
If you have git clones from prior to the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone:
@ -194,27 +185,36 @@ git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git
Please *don't* use the SourceForge or Google Code projects any more; they are obsolete and no longer maintained.
## Sponsorship
Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), a powerful email marketing system.
Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), the world's only privacy-first email marketing system.
<a href="https://info.smartmessages.net/"><img src="https://www.smartmessages.net/img/smartmessages-logo.svg" width="250" height="28" alt="Smartmessages email marketing"></a>
<a href="https://info.smartmessages.net/"><img src="https://www.smartmessages.net/img/smartmessages-logo.svg" width="550" alt="Smartmessages.net privacy-first email marketing logo"></a>
Other contributions are gladly received, whether in beer 🍺, T-shirts 👕, Amazon wishlist raids, or cold, hard cash 💰. If you'd like to donate to say "thank you" to maintainers or contributors, please contact them through individual profile pages via [the contributors page](https://github.com/PHPMailer/PHPMailer/graphs/contributors).
Donations are very welcome, whether in beer 🍺, T-shirts 👕, or cold, hard cash 💰. Sponsorship through GitHub is a simple and convenient way to say "thank you" to PHPMailer's maintainers and contributors just click the "Sponsor" button [on the project page](https://github.com/PHPMailer/PHPMailer). If your company uses PHPMailer, consider taking part in Tidelift's enterprise support programme.
## PHPMailer For Enterprise
Available as part of the Tidelift Subscription.
The maintainers of PHPMailer and thousands of other packages are working with Tidelift to deliver commercial
support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and
improve code health, while paying the maintainers of the exact packages you
use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-phpmailer-phpmailer?utm_source=packagist-phpmailer-phpmailer&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Changelog
See [changelog](changelog.md).
## History
- PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/).
- Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004.
- [Marcus Bointon](https://github.com/Synchro) (`coolbru` on SF) and Andy Prevost (`codeworxtech`) took over the project in 2004.
- Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski.
- Marcus created his fork on [GitHub](https://github.com/Synchro/PHPMailer) in 2008.
- Marcus created [his fork on GitHub](https://github.com/Synchro/PHPMailer) in 2008.
- Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer in 2013.
- PHPMailer moves to the [PHPMailer organisation](https://github.com/PHPMailer) on GitHub in 2013.
- PHPMailer moves to [the PHPMailer organisation](https://github.com/PHPMailer) on GitHub in 2013.
### What's changed since moving from SourceForge?
- Official successor to the SourceForge and Google Code projects.
- Test suite.
- Continuous integration with Travis-CI.
- Continuous integration with Github Actions.
- Composer support.
- Public development.
- Additional languages and language strings.

4
phpmailer/SECURITY.md Executable file → Normal file
View File

@ -1,6 +1,8 @@
# Security notices relating to PHPMailer
Please disclose any vulnerabilities found responsibly - report any security problems found to the maintainers privately.
Please disclose any security issues or vulnerabilities found through [Tidelift's coordinated disclosure system](https://tidelift.com/security) or to the maintainers privately.
PHPMailer versions 6.1.5 and earlier contain an output escaping bug that occurs in `Content-Type` and `Content-Disposition` when filenames passed into `addAttachment` and other methods that accept attachment names contain double quote characters, in contravention of RFC822 3.4.1. No specific vulnerability has been found relating to this, but it could allow file attachments to bypass attachment filters that are based on matching filename extensions. Recorded as [CVE-2020-13625](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2020-13625). Reported by Elar Lang of Clarified Security.
PHPMailer versions prior to 6.0.6 and 5.2.27 are vulnerable to an object injection attack by passing `phar://` paths into `addAttachment()` and other functions that may receive unfiltered local paths, possibly leading to RCE. Recorded as [CVE-2018-19296](https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2018-19296). See [this article](https://knasmueller.net/5-answers-about-php-phar-exploitation) for more info on this type of vulnerability. Mitigated by blocking the use of paths containing URL-protocol style prefixes such as `phar://`. Reported by Sehun Oh of cyberone.kr.

2
phpmailer/VERSION Executable file → Normal file
View File

@ -1 +1 @@
6.0.7
6.4.0

28
phpmailer/composer.json Executable file → Normal file
View File

@ -19,26 +19,32 @@
"name": "Brent R. Matzelle"
}
],
"funding": [
{
"url": "https://github.com/Synchro",
"type": "github"
}
],
"require": {
"php": ">=5.5.0",
"ext-ctype": "*",
"ext-filter": "*"
"ext-filter": "*",
"ext-hash": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2",
"phpdocumentor/phpdocumentor": "2.*",
"phpunit/phpunit": "^4.8 || ^5.7",
"zendframework/zend-serializer": "2.7.*",
"doctrine/annotations": "1.2.*",
"zendframework/zend-eventmanager": "3.0.*",
"zendframework/zend-i18n": "2.7.3"
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"doctrine/annotations": "^1.2",
"phpcompatibility/php-compatibility": "^9.3.5",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.5.6",
"yoast/phpunit-polyfills": "^0.2.0"
},
"suggest": {
"psr/log": "For optional PSR-3 debug logging",
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
"hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication",
"league/oauth2-google": "Needed for Google XOAUTH2 authentication",
"psr/log": "For optional PSR-3 debug logging",
"stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication",
"ext-mbstring": "Needed to send email in multibyte encoding charset",
"symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)"
},
"autoload": {

34
phpmailer/get_oauth_token.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.5
@ -8,7 +9,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2012 - 2020 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -16,6 +17,7 @@
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Get an OAuth2 token from an OAuth2 provider.
* * Install this script on your server so that it's accessible
@ -36,24 +38,24 @@ namespace PHPMailer\PHPMailer;
* Plenty to choose from here:
* @see http://oauth2-client.thephpleague.com/providers/thirdparty/
*/
// @see https://github.com/thephpleague/oauth2-google
//@see https://github.com/thephpleague/oauth2-google
use League\OAuth2\Client\Provider\Google;
// @see https://packagist.org/packages/hayageek/oauth2-yahoo
//@see https://packagist.org/packages/hayageek/oauth2-yahoo
use Hayageek\OAuth2\Client\Provider\Yahoo;
// @see https://github.com/stevenmaguire/oauth2-microsoft
//@see https://github.com/stevenmaguire/oauth2-microsoft
use Stevenmaguire\OAuth2\Client\Provider\Microsoft;
if (!isset($_GET['code']) && !isset($_GET['provider'])) {
?>
?>
<html>
<body>Select Provider:<br/>
<a href='?provider=Google'>Google</a><br/>
<a href='?provider=Yahoo'>Yahoo</a><br/>
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br/>
<body>Select Provider:<br>
<a href='?provider=Google'>Google</a><br>
<a href='?provider=Yahoo'>Yahoo</a><br>
<a href='?provider=Microsoft'>Microsoft/Outlook/Hotmail/Live/Office365</a><br>
</body>
</html>
<?php
exit;
<?php
exit;
}
require 'vendor/autoload.php';
@ -119,26 +121,26 @@ if (null === $provider) {
}
if (!isset($_GET['code'])) {
// If we don't have an authorization code then get one
//If we don't have an authorization code then get one
$authUrl = $provider->getAuthorizationUrl($options);
$_SESSION['oauth2state'] = $provider->getState();
header('Location: ' . $authUrl);
exit;
// Check given state against previously stored one to mitigate CSRF attack
//Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
unset($_SESSION['provider']);
exit('Invalid state');
} else {
unset($_SESSION['provider']);
// Try to get an access token (using the authorization code grant)
//Try to get an access token (using the authorization code grant)
$token = $provider->getAccessToken(
'authorization_code',
[
'code' => $_GET['code']
]
);
// Use this to interact with an API on the users behalf
// Use this to get a new access token if the old one expires
//Use this to interact with an API on the users behalf
//Use this to get a new access token if the old one expires
echo 'Refresh Token: ', $token->getRefreshToken();
}

1
phpmailer/language/phpmailer.lang-af.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ar.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-az.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ba.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-be.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-bg.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ca.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ch.php Executable file → Normal file
View File

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

3
phpmailer/language/phpmailer.lang-cs.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* Czech PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
@ -15,6 +16,8 @@ $PHPMAILER_LANG['file_open'] = 'Chyba souboru: Nelze otevřít soubor
$PHPMAILER_LANG['from_failed'] = 'Následující adresa odesílatele je nesprávná: ';
$PHPMAILER_LANG['instantiate'] = 'Nelze vytvořit instanci emailové funkce.';
$PHPMAILER_LANG['invalid_address'] = 'Neplatná adresa: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'Záznam hostitele je nesprávný: ';
$PHPMAILER_LANG['invalid_host'] = 'Hostitel je nesprávný: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer není podporován.';
$PHPMAILER_LANG['provide_address'] = 'Musíte zadat alespoň jednu emailovou adresu příjemce.';
$PHPMAILER_LANG['recipients_failed'] = 'Chyba SMTP: Následující adresy příjemců nejsou správně: ';

33
phpmailer/language/phpmailer.lang-da.php Executable file → Normal file
View File

@ -1,26 +1,29 @@
<?php
/**
* Danish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
* @author Mikael Stokkebro <info@stokkebro.dk>
* @author John Sebastian <jms@iwb.dk>
* Rewrite and extension of the work by Mikael Stokkebro <info@stokkebro.dk>
*
*/
$PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Kunne ikke logge på.';
$PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data kunne ikke accepteres.';
//$PHPMAILER_LANG['empty_message'] = 'Message body empty';
$PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Login mislykkedes.';
$PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Forbindelse til SMTP serveren kunne ikke oprettes.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data blev ikke accepteret.';
$PHPMAILER_LANG['empty_message'] = 'Meddelelsen er uden indhold';
$PHPMAILER_LANG['encoding'] = 'Ukendt encode-format: ';
$PHPMAILER_LANG['execute'] = 'Kunne ikke køre: ';
$PHPMAILER_LANG['file_access'] = 'Ingen adgang til fil: ';
$PHPMAILER_LANG['execute'] = 'Kunne ikke afvikle: ';
$PHPMAILER_LANG['file_access'] = 'Kunne ikke tilgå filen: ';
$PHPMAILER_LANG['file_open'] = 'Fil fejl: Kunne ikke åbne filen: ';
$PHPMAILER_LANG['from_failed'] = 'Følgende afsenderadresse er forkert: ';
$PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere email funktionen.';
//$PHPMAILER_LANG['invalid_address'] = 'Invalid address: ';
$PHPMAILER_LANG['instantiate'] = 'Email funktionen kunne ikke initialiseres.';
$PHPMAILER_LANG['invalid_address'] = 'Udgyldig adresse: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.';
$PHPMAILER_LANG['provide_address'] = 'Du skal indtaste mindst en modtagers emailadresse.';
$PHPMAILER_LANG['provide_address'] = 'Indtast mindst en modtagers email adresse.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP fejl: Følgende modtagere er forkerte: ';
//$PHPMAILER_LANG['signing'] = 'Signing Error: ';
//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.';
//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: ';
//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: ';
$PHPMAILER_LANG['signing'] = 'Signeringsfejl: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() fejlede.';
$PHPMAILER_LANG['smtp_error'] = 'SMTP server fejl: ';
$PHPMAILER_LANG['variable_set'] = 'Kunne ikke definere eller nulstille variablen: ';
$PHPMAILER_LANG['extension_missing'] = 'Udvidelse mangler: ';

3
phpmailer/language/phpmailer.lang-de.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* German PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
@ -15,6 +16,8 @@ $PHPMAILER_LANG['file_open'] = 'Dateifehler: Konnte folgende Datei ni
$PHPMAILER_LANG['from_failed'] = 'Die folgende Absenderadresse ist nicht korrekt: ';
$PHPMAILER_LANG['instantiate'] = 'Mail-Funktion konnte nicht initialisiert werden.';
$PHPMAILER_LANG['invalid_address'] = 'Die Adresse ist ungültig: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'Ungültiger Hosteintrag: ';
$PHPMAILER_LANG['invalid_host'] = 'Ungültiger Host: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wird nicht unterstützt.';
$PHPMAILER_LANG['provide_address'] = 'Bitte geben Sie mindestens eine Empfängeradresse an.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP-Fehler: Die folgenden Empfänger sind nicht korrekt: ';

1
phpmailer/language/phpmailer.lang-el.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-eo.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-es.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-et.php Executable file → Normal file
View File

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

3
phpmailer/language/phpmailer.lang-fa.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* Persian/Farsi PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
@ -24,4 +25,4 @@ $PHPMAILER_LANG['signing'] = 'خطا در امضا: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'خطا در اتصال به SMTP.';
$PHPMAILER_LANG['smtp_error'] = 'خطا در SMTP Server: ';
$PHPMAILER_LANG['variable_set'] = 'امکان ارسال یا ارسال مجدد متغیر‌ها وجود ندارد: ';
//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: ';
$PHPMAILER_LANG['extension_missing'] = 'افزونه موجود نیست: ';

1
phpmailer/language/phpmailer.lang-fi.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-fo.php Executable file → Normal file
View File

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

3
phpmailer/language/phpmailer.lang-fr.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* French PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
@ -19,6 +20,8 @@ $PHPMAILER_LANG['file_open'] = 'Ouverture du fichier impossible: '
$PHPMAILER_LANG['from_failed'] = 'L\'adresse d\'expéditeur suivante a échoué: ';
$PHPMAILER_LANG['instantiate'] = 'Impossible d\'instancier la fonction mail.';
$PHPMAILER_LANG['invalid_address'] = 'L\'adresse courriel n\'est pas valide: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'L\'entrée hôte n\'est pas valide: ';
$PHPMAILER_LANG['invalid_host'] = 'L\'hôte n\'est pas valide: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' client de messagerie non supporté.';
$PHPMAILER_LANG['provide_address'] = 'Vous devez fournir au moins une adresse de destinataire.';
$PHPMAILER_LANG['recipients_failed'] = 'Erreur SMTP: les destinataires suivants sont en erreur: ';

1
phpmailer/language/phpmailer.lang-gl.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-he.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-hi.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-hr.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-hu.php Executable file → Normal file
View File

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

View File

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

28
phpmailer/language/phpmailer.lang-id.php Executable file → Normal file
View File

@ -1,9 +1,11 @@
<?php
/**
* Indonesian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
* @author Cecep Prawiro <cecep.prawiro@gmail.com>
* @author @januridp
* @author Ian Mustafa <mail@ianmustafa.com>
*/
$PHPMAILER_LANG['authenticate'] = 'Kesalahan SMTP: Tidak dapat mengotentikasi.';
@ -11,17 +13,19 @@ $PHPMAILER_LANG['connect_host'] = 'Kesalahan SMTP: Tidak dapat terhubung
$PHPMAILER_LANG['data_not_accepted'] = 'Kesalahan SMTP: Data tidak diterima.';
$PHPMAILER_LANG['empty_message'] = 'Isi pesan kosong';
$PHPMAILER_LANG['encoding'] = 'Pengkodean karakter tidak dikenali: ';
$PHPMAILER_LANG['execute'] = 'Tidak dapat menjalankan proses : ';
$PHPMAILER_LANG['file_access'] = 'Tidak dapat mengakses berkas : ';
$PHPMAILER_LANG['file_open'] = 'Kesalahan File: Berkas tidak dapat dibuka : ';
$PHPMAILER_LANG['from_failed'] = 'Alamat pengirim berikut mengakibatkan kesalahan : ';
$PHPMAILER_LANG['instantiate'] = 'Tidak dapat menginisialisasi fungsi surel';
$PHPMAILER_LANG['invalid_address'] = 'Gagal terkirim, alamat surel tidak benar : ';
$PHPMAILER_LANG['provide_address'] = 'Harus disediakan minimal satu alamat tujuan';
$PHPMAILER_LANG['execute'] = 'Tidak dapat menjalankan proses: ';
$PHPMAILER_LANG['file_access'] = 'Tidak dapat mengakses berkas: ';
$PHPMAILER_LANG['file_open'] = 'Kesalahan Berkas: Berkas tidak dapat dibuka: ';
$PHPMAILER_LANG['from_failed'] = 'Alamat pengirim berikut mengakibatkan kesalahan: ';
$PHPMAILER_LANG['instantiate'] = 'Tidak dapat menginisialisasi fungsi surel.';
$PHPMAILER_LANG['invalid_address'] = 'Gagal terkirim, alamat surel tidak sesuai: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'Gagal terkirim, entri host tidak sesuai: ';
$PHPMAILER_LANG['invalid_host'] = 'Gagal terkirim, host tidak sesuai: ';
$PHPMAILER_LANG['provide_address'] = 'Harus tersedia minimal satu alamat tujuan';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer tidak didukung';
$PHPMAILER_LANG['recipients_failed'] = 'Kesalahan SMTP: Alamat tujuan berikut menghasilkan kesalahan : ';
$PHPMAILER_LANG['signing'] = 'Kesalahan dalam tanda tangan : ';
$PHPMAILER_LANG['recipients_failed'] = 'Kesalahan SMTP: Alamat tujuan berikut menyebabkan kesalahan: ';
$PHPMAILER_LANG['signing'] = 'Kesalahan dalam penandatangan SSL: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() gagal.';
$PHPMAILER_LANG['smtp_error'] = 'Kesalahan pada pelayan SMTP : ';
$PHPMAILER_LANG['variable_set'] = 'Tidak dapat mengatur atau mengatur ulang variable : ';
$PHPMAILER_LANG['extension_missing'] = 'Ekstensi hilang: ';
$PHPMAILER_LANG['smtp_error'] = 'Kesalahan pada pelayan SMTP: ';
$PHPMAILER_LANG['variable_set'] = 'Tidak dapat mengatur atau mengatur ulang variabel: ';
$PHPMAILER_LANG['extension_missing'] = 'Ekstensi PHP tidak tersedia: ';

1
phpmailer/language/phpmailer.lang-it.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ja.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ka.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ko.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-lt.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-lv.php Executable file → Normal file
View File

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

2
phpmailer/language/phpmailer.lang-mg.php Executable file → Normal file
View File

@ -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
phpmailer/language/phpmailer.lang-ms.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-nb.php Executable file → Normal file
View File

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

3
phpmailer/language/phpmailer.lang-nl.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* Dutch PHPMailer language file: refer to PHPMailer.php for definitive list.
* @package PHPMailer
@ -16,6 +17,8 @@ $PHPMAILER_LANG['file_open'] = 'Bestandsfout: kon bestand niet openen
$PHPMAILER_LANG['from_failed'] = 'Het volgende afzendersadres is mislukt: ';
$PHPMAILER_LANG['instantiate'] = 'Kon mailfunctie niet initialiseren.';
$PHPMAILER_LANG['invalid_address'] = 'Ongeldig adres: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'Ongeldige hostentry: ';
$PHPMAILER_LANG['invalid_host'] = 'Ongeldige host: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wordt niet ondersteund.';
$PHPMAILER_LANG['provide_address'] = 'Er moet minstens één ontvanger worden opgegeven.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP-fout: de volgende ontvangers zijn mislukt: ';

3
phpmailer/language/phpmailer.lang-pl.php Executable file → Normal file
View File

@ -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
phpmailer/language/phpmailer.lang-pt.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-pt_br.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ro.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-ru.php Executable file → Normal file
View File

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

3
phpmailer/language/phpmailer.lang-sk.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* Slovak PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
@ -17,6 +18,8 @@ $PHPMAILER_LANG['file_open'] = 'File Error: Súbor sa otvoriť pre č
$PHPMAILER_LANG['from_failed'] = 'Následujúca adresa From je nesprávna: ';
$PHPMAILER_LANG['instantiate'] = 'Nedá sa vytvoriť inštancia emailovej funkcie.';
$PHPMAILER_LANG['invalid_address'] = 'Neodoslané, emailová adresa je nesprávna: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'Záznam hostiteľa je nesprávny: ';
$PHPMAILER_LANG['invalid_host'] = 'Hostiteľ je nesprávny: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' emailový klient nieje podporovaný.';
$PHPMAILER_LANG['provide_address'] = 'Musíte zadať aspoň jednu emailovú adresu príjemcu.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Adresy príjemcov niesu správne ';

6
phpmailer/language/phpmailer.lang-sl.php Executable file → Normal file
View File

@ -1,9 +1,11 @@
<?php
/**
* Slovene PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
* @author Klemen Tušar <techouse@gmail.com>
* @author Filip Š <projects@filips.si>
* @author Blaž Oražem <blaz@orazem.si>
*/
$PHPMAILER_LANG['authenticate'] = 'SMTP napaka: Avtentikacija ni uspela.';
@ -17,8 +19,10 @@ $PHPMAILER_LANG['file_open'] = 'Ne morem odpreti datoteke: ';
$PHPMAILER_LANG['from_failed'] = 'Neveljaven e-naslov pošiljatelja: ';
$PHPMAILER_LANG['instantiate'] = 'Ne morem inicializirati mail funkcije.';
$PHPMAILER_LANG['invalid_address'] = 'E-poštno sporočilo ni bilo poslano. E-naslov je neveljaven: ';
$PHPMAILER_LANG['invalid_hostentry'] = 'Neveljaven vnos gostitelja: ';
$PHPMAILER_LANG['invalid_host'] = 'Neveljaven gostitelj: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer ni podprt.';
$PHPMAILER_LANG['provide_address'] = 'Prosim vnesite vsaj enega naslovnika.';
$PHPMAILER_LANG['provide_address'] = 'Prosimo, vnesite vsaj enega naslovnika.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP napaka: Sledeči naslovniki so neveljavni: ';
$PHPMAILER_LANG['signing'] = 'Napaka pri podpisovanju: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Ne morem vzpostaviti povezave s SMTP strežnikom.';

1
phpmailer/language/phpmailer.lang-sr.php Executable file → Normal file
View File

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

View File

@ -0,0 +1,28 @@
<?php
/**
* Serbian PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
* @author Александар Јевремовић <ajevremovic@gmail.com>
* @author Miloš Milanović <mmilanovic016@gmail.com>
*/
$PHPMAILER_LANG['authenticate'] = 'SMTP greška: autentifikacija nije uspela.';
$PHPMAILER_LANG['connect_host'] = 'SMTP greška: povezivanje sa SMTP serverom nije uspelo.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP greška: podaci nisu prihvaćeni.';
$PHPMAILER_LANG['empty_message'] = 'Sadržaj poruke je prazan.';
$PHPMAILER_LANG['encoding'] = 'Nepoznato kodiranje: ';
$PHPMAILER_LANG['execute'] = 'Nije moguće izvršiti naredbu: ';
$PHPMAILER_LANG['file_access'] = 'Nije moguće pristupiti datoteci: ';
$PHPMAILER_LANG['file_open'] = 'Nije moguće otvoriti datoteku: ';
$PHPMAILER_LANG['from_failed'] = 'SMTP greška: slanje sa sledećih adresa nije uspelo: ';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP greška: slanje na sledeće adrese nije uspelo: ';
$PHPMAILER_LANG['instantiate'] = 'Nije moguće pokrenuti mail funkciju.';
$PHPMAILER_LANG['invalid_address'] = 'Poruka nije poslata. Neispravna adresa: ';
$PHPMAILER_LANG['mailer_not_supported'] = ' majler nije podržan.';
$PHPMAILER_LANG['provide_address'] = 'Definišite bar jednu adresu primaoca.';
$PHPMAILER_LANG['signing'] = 'Greška prilikom prijave: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Povezivanje sa SMTP serverom nije uspelo.';
$PHPMAILER_LANG['smtp_error'] = 'Greška SMTP servera: ';
$PHPMAILER_LANG['variable_set'] = 'Nije moguće zadati niti resetovati promenljivu: ';
$PHPMAILER_LANG['extension_missing'] = 'Nedostaje proširenje: ';

5
phpmailer/language/phpmailer.lang-sv.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* Swedish PHPMailer language file: refer to English translation for definitive list
* @package PHPMailer
@ -19,8 +20,8 @@ $PHPMAILER_LANG['invalid_address'] = 'Felaktig adress: ';
$PHPMAILER_LANG['provide_address'] = 'Du måste ange minst en mottagares e-postadress.';
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP fel: Följande mottagare är felaktig: ';
$PHPMAILER_LANG['signing'] = 'Signerings fel: ';
$PHPMAILER_LANG['signing'] = 'Signeringsfel: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() misslyckades.';
$PHPMAILER_LANG['smtp_error'] = 'SMTP server fel: ';
$PHPMAILER_LANG['smtp_error'] = 'SMTP serverfel: ';
$PHPMAILER_LANG['variable_set'] = 'Kunde inte definiera eller återställa variabel: ';
$PHPMAILER_LANG['extension_missing'] = 'Tillägg ej tillgängligt: ';

23
phpmailer/language/phpmailer.lang-tl.php Executable file → Normal file
View File

@ -1,27 +1,28 @@
<?php
/**
* Tagalog PHPMailer language file: refer to English translation for definitive list
*
* @package PHPMailer
* @author Adriane Justine Tan <adrianetan12@gmail.com>
* @author Adriane Justine Tan <eidoriantan@gmail.com>
*/
$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Hindi mapatotohanan.';
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Hindi makakonekta sa SMTP host.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Ang datos ay hindi maaaring matatanggap.';
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Ang datos ay hindi naitanggap.';
$PHPMAILER_LANG['empty_message'] = 'Walang laman ang mensahe';
$PHPMAILER_LANG['encoding'] = 'Hindi alam ang encoding: ';
$PHPMAILER_LANG['execute'] = 'Hindi maisasagawa: ';
$PHPMAILER_LANG['file_access'] = 'Hindi ma-access ang file: ';
$PHPMAILER_LANG['file_open'] = 'Hindi mabuksan ang file: ';
$PHPMAILER_LANG['file_open'] = 'File Error: Hindi mabuksan ang file: ';
$PHPMAILER_LANG['from_failed'] = 'Ang sumusunod na address ay nabigo: ';
$PHPMAILER_LANG['instantiate'] = 'Hindi maaaring magbigay ng institusyon ang mail';
$PHPMAILER_LANG['instantiate'] = 'Hindi maisimulan ang instance ng mail function.';
$PHPMAILER_LANG['invalid_address'] = 'Hindi wasto ang address na naibigay: ';
$PHPMAILER_LANG['mailer_not_supported'] = 'Ang mailer ay hindi suportado';
$PHPMAILER_LANG['provide_address'] = 'Kailangan mong magbigay ng kahit isang email address na tatanggap';
$PHPMAILER_LANG['mailer_not_supported'] = 'Ang mailer ay hindi suportado.';
$PHPMAILER_LANG['provide_address'] = 'Kailangan mong magbigay ng kahit isang email address na tatanggap.';
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: Ang mga sumusunod na tatanggap ay nabigo: ';
$PHPMAILER_LANG['signing'] = 'Hindi ma-sign';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Ang SMTP connect() ay nabigo';
$PHPMAILER_LANG['smtp_error'] = 'Ang server ng SMTP ay nabigo';
$PHPMAILER_LANG['variable_set'] = 'Hindi matatakda ang mga variables: ';
$PHPMAILER_LANG['extension_missing'] = 'Nawawala ang extension';
$PHPMAILER_LANG['signing'] = 'Hindi ma-sign: ';
$PHPMAILER_LANG['smtp_connect_failed'] = 'Ang SMTP connect() ay nabigo.';
$PHPMAILER_LANG['smtp_error'] = 'Ang server ng SMTP ay nabigo: ';
$PHPMAILER_LANG['variable_set'] = 'Hindi matatakda o ma-reset ang mga variables: ';
$PHPMAILER_LANG['extension_missing'] = 'Nawawala ang extension: ';

1
phpmailer/language/phpmailer.lang-tr.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-uk.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-vi.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-zh.php Executable file → Normal file
View File

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

1
phpmailer/language/phpmailer.lang-zh_cn.php Executable file → Normal file
View File

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

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="true"
bootstrap="vendor/autoload.php"
verbose="true"
colors="true"
forceCoversAnnotation="false"
>
<testsuites>
<testsuite name="PHPMailerTests">
<directory>./test/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="PHPMailer\Test\DebugLogTestListener" />
</listeners>
<groups>
<exclude>
<group>languages</group>
<group>pop3</group>
</exclude>
</groups>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml"/>
</logging>
</phpunit>

3
phpmailer/src/Exception.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* PHPMailer Exception class.
* PHP Version 5.5.
@ -9,7 +10,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2012 - 2020 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License

7
phpmailer/src/OAuth.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* PHPMailer - PHP email creation and transport class.
* PHP Version 5.5.
@ -9,7 +10,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2015 Marcus Bointon
* @copyright 2012 - 2020 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -122,8 +123,8 @@ class OAuth
*/
public function getOauth64()
{
// Get a new token if it's not available or has expired
if (null === $this->oauthToken or $this->oauthToken->hasExpired()) {
//Get a new token if it's not available or has expired
if (null === $this->oauthToken || $this->oauthToken->hasExpired()) {
$this->oauthToken = $this->getToken();
}

1386
phpmailer/src/PHPMailer.php Executable file → Normal file

File diff suppressed because it is too large Load Diff

91
phpmailer/src/POP3.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* PHPMailer POP-Before-SMTP Authentication Class.
* PHP Version 5.5.
@ -9,7 +10,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2012 - 2020 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -29,7 +30,7 @@ namespace PHPMailer\PHPMailer;
* and then loop through your mail sending script. Providing this process doesn't
* take longer than the verification period lasts on your POP3 server, you should be fine.
* 3) This is really ancient technology; you should only need to use it to talk to very old systems.
* 4) This POP3 class is deliberately lightweight and incomplete, and implements just
* 4) This POP3 class is deliberately lightweight and incomplete, implementing just
* enough to do authentication.
* If you want a more complete class there are other POP3 classes for PHP available.
*
@ -45,7 +46,7 @@ class POP3
*
* @var string
*/
const VERSION = '6.0.7';
const VERSION = '6.4.0';
/**
* Default POP3 port number.
@ -62,12 +63,16 @@ class POP3
const DEFAULT_TIMEOUT = 30;
/**
* Debug display level.
* Options: 0 = no, 1+ = yes.
* POP3 class debug output mode.
* Debug output level.
* Options:
* @see POP3::DEBUG_OFF: No output
* @see POP3::DEBUG_SERVER: Server messages, connection/server errors
* @see POP3::DEBUG_CLIENT: Client and Server messages, connection/server errors
*
* @var int
*/
public $do_debug = 0;
public $do_debug = self::DEBUG_OFF;
/**
* POP3 mail server hostname.
@ -130,6 +135,28 @@ class POP3
*/
const LE = "\r\n";
/**
* Debug level for no output.
*
* @var int
*/
const DEBUG_OFF = 0;
/**
* Debug level to show server -> client messages
* also shows clients connection errors or errors from server
*
* @var int
*/
const DEBUG_SERVER = 1;
/**
* Debug level to show client -> server and server -> client messages.
*
* @var int
*/
const DEBUG_CLIENT = 2;
/**
* Simple static wrapper for all-in-one POP before SMTP.
*
@ -172,13 +199,13 @@ class POP3
public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
{
$this->host = $host;
// If no port value provided, use default
//If no port value provided, use default
if (false === $port) {
$this->port = static::DEFAULT_PORT;
} else {
$this->port = (int) $port;
}
// If no timeout value provided, use default
//If no timeout value provided, use default
if (false === $timeout) {
$this->tval = static::DEFAULT_TIMEOUT;
} else {
@ -187,9 +214,9 @@ class POP3
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Reset the error log
//Reset the error log
$this->errors = [];
// connect
//Connect
$result = $this->connect($this->host, $this->port, $this->tval);
if ($result) {
$login_result = $this->login($this->username, $this->password);
@ -199,7 +226,7 @@ class POP3
return true;
}
}
// We need to disconnect regardless of whether the login succeeded
//We need to disconnect regardless of whether the login succeeded
$this->disconnect();
return false;
@ -216,7 +243,7 @@ class POP3
*/
public function connect($host, $port = false, $tval = 30)
{
// Are we already connected?
//Are we already connected?
if ($this->connected) {
return true;
}
@ -229,20 +256,22 @@ class POP3
$port = static::DEFAULT_PORT;
}
// connect to the POP3 server
//Connect to the POP3 server
$errno = 0;
$errstr = '';
$this->pop_conn = fsockopen(
$host, // POP3 Host
$port, // Port #
$errno, // Error Number
$errstr, // Error Message
$host, //POP3 Host
$port, //Port #
$errno, //Error Number
$errstr, //Error Message
$tval
); // Timeout (seconds)
// Restore the error handler
); //Timeout (seconds)
//Restore the error handler
restore_error_handler();
// Did we connect?
//Did we connect?
if (false === $this->pop_conn) {
// It would appear not...
//It would appear not...
$this->setError(
"Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr"
);
@ -250,14 +279,14 @@ class POP3
return false;
}
// Increase the stream time-out
//Increase the stream time-out
stream_set_timeout($this->pop_conn, $tval, 0);
// Get the POP3 server response
//Get the POP3 server response
$pop3_response = $this->getResponse();
// Check for the +OK
//Check for the +OK
if ($this->checkResponse($pop3_response)) {
// The connection is established and the POP3 server is talking
//The connection is established and the POP3 server is talking
$this->connected = true;
return true;
@ -287,11 +316,11 @@ class POP3
$password = $this->password;
}
// Send the Username
//Send the Username
$this->sendString("USER $username" . static::LE);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
// Send the Password
//Send the Password
$this->sendString("PASS $password" . static::LE);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response)) {
@ -327,7 +356,7 @@ class POP3
protected function getResponse($size = 128)
{
$response = fgets($this->pop_conn, $size);
if ($this->do_debug >= 1) {
if ($this->do_debug >= self::DEBUG_SERVER) {
echo 'Server -> Client: ', $response;
}
@ -344,7 +373,7 @@ class POP3
protected function sendString($string)
{
if ($this->pop_conn) {
if ($this->do_debug >= 2) { //Show client messages when debug >= 2
if ($this->do_debug >= self::DEBUG_CLIENT) { //Show client messages when debug >= 2
echo 'Client -> Server: ', $string;
}
@ -364,7 +393,7 @@ class POP3
*/
protected function checkResponse($string)
{
if (substr($string, 0, 3) !== '+OK') {
if (strpos($string, '+OK') !== 0) {
$this->setError("Server reported an error: $string");
return false;
@ -382,7 +411,7 @@ class POP3
protected function setError($error)
{
$this->errors[] = $error;
if ($this->do_debug >= 1) {
if ($this->do_debug >= self::DEBUG_SERVER) {
echo '<pre>';
foreach ($this->errors as $e) {
print_r($e);

302
phpmailer/src/SMTP.php Executable file → Normal file
View File

@ -1,4 +1,5 @@
<?php
/**
* PHPMailer RFC821 SMTP email transport class.
* PHP Version 5.5.
@ -9,7 +10,7 @@
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2017 Marcus Bointon
* @copyright 2012 - 2020 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
@ -34,7 +35,7 @@ class SMTP
*
* @var string
*/
const VERSION = '6.0.7';
const VERSION = '6.4.0';
/**
* SMTP line break constant.
@ -51,34 +52,57 @@ class SMTP
const DEFAULT_PORT = 25;
/**
* The maximum line length allowed by RFC 2822 section 2.1.1.
* The maximum line length allowed by RFC 5321 section 4.5.3.1.6,
* *excluding* a trailing CRLF break.
*
* @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.6
*
* @var int
*/
const MAX_LINE_LENGTH = 998;
/**
* The maximum line length allowed for replies in RFC 5321 section 4.5.3.1.5,
* *including* a trailing CRLF line break.
*
* @see https://tools.ietf.org/html/rfc5321#section-4.5.3.1.5
*
* @var int
*/
const MAX_REPLY_LENGTH = 512;
/**
* Debug level for no output.
*
* @var int
*/
const DEBUG_OFF = 0;
/**
* Debug level to show client -> server messages.
*
* @var int
*/
const DEBUG_CLIENT = 1;
/**
* Debug level to show client -> server and server -> client messages.
*
* @var int
*/
const DEBUG_SERVER = 2;
/**
* Debug level to show connection status, client -> server and server -> client messages.
*
* @var int
*/
const DEBUG_CONNECTION = 3;
/**
* Debug level to show all messages.
*
* @var int
*/
const DEBUG_LOWLEVEL = 4;
@ -197,7 +221,7 @@ class SMTP
*
* @var string|null
*/
protected $helo_rply = null;
protected $helo_rply;
/**
* The set of SMTP extensions sent in reply to EHLO command.
@ -209,7 +233,7 @@ class SMTP
*
* @var array|null
*/
protected $server_caps = null;
protected $server_caps;
/**
* The most recent reply received from the server.
@ -239,7 +263,7 @@ class SMTP
return;
}
//Avoid clash with built-in function names
if (!in_array($this->Debugoutput, ['error_log', 'html', 'echo']) and is_callable($this->Debugoutput)) {
if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) {
call_user_func($this->Debugoutput, $str, $level);
return;
@ -260,7 +284,7 @@ class SMTP
case 'echo':
default:
//Normalize line breaks
$str = preg_replace('/\r\n|\r/ms', "\n", $str);
$str = preg_replace('/\r\n|\r/m', "\n", $str);
echo gmdate('Y-m-d H:i:s'),
"\t",
//Trim trailing space
@ -288,17 +312,11 @@ class SMTP
*/
public function connect($host, $port = null, $timeout = 30, $options = [])
{
static $streamok;
//This is enabled by default since 5.0.0 but some providers disable it
//Check this once and cache the result
if (null === $streamok) {
$streamok = function_exists('stream_socket_client');
}
// Clear errors to avoid confusion
//Clear errors to avoid confusion
$this->setError('');
// Make sure we are __not__ connected
//Make sure we are __not__ connected
if ($this->connected()) {
// Already connected, generate error
//Already connected, generate error
$this->setError('Already connected to a server');
return false;
@ -306,18 +324,66 @@ class SMTP
if (empty($port)) {
$port = self::DEFAULT_PORT;
}
// Connect to the SMTP server
//Connect to the SMTP server
$this->edebug(
"Connection: opening to $host:$port, timeout=$timeout, options=" .
(count($options) > 0 ? var_export($options, true) : 'array()'),
self::DEBUG_CONNECTION
);
$this->smtp_conn = $this->getSMTPConnection($host, $port, $timeout, $options);
if ($this->smtp_conn === false) {
//Error info already set inside `getSMTPConnection()`
return false;
}
$this->edebug('Connection: opened', self::DEBUG_CONNECTION);
//Get any announcement
$this->last_reply = $this->get_lines();
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
$responseCode = (int)substr($this->last_reply, 0, 3);
if ($responseCode === 220) {
return true;
}
//Anything other than a 220 response means something went wrong
//RFC 5321 says the server will wait for us to send a QUIT in response to a 554 error
//https://tools.ietf.org/html/rfc5321#section-3.1
if ($responseCode === 554) {
$this->quit();
}
//This will handle 421 responses which may not wait for a QUIT (e.g. if the server is being shut down)
$this->edebug('Connection: closing due to error', self::DEBUG_CONNECTION);
$this->close();
return false;
}
/**
* Create connection to the SMTP server.
*
* @param string $host SMTP server IP or host name
* @param int $port The port number to connect to
* @param int $timeout How long to wait for the connection to open
* @param array $options An array of options for stream_context_create()
*
* @return false|resource
*/
protected function getSMTPConnection($host, $port = null, $timeout = 30, $options = [])
{
static $streamok;
//This is enabled by default since 5.0.0 but some providers disable it
//Check this once and cache the result
if (null === $streamok) {
$streamok = function_exists('stream_socket_client');
}
$errno = 0;
$errstr = '';
if ($streamok) {
$socket_context = stream_context_create($options);
set_error_handler([$this, 'errorHandler']);
$this->smtp_conn = stream_socket_client(
$connection = stream_socket_client(
$host . ':' . $port,
$errno,
$errstr,
@ -333,7 +399,7 @@ class SMTP
self::DEBUG_CONNECTION
);
set_error_handler([$this, 'errorHandler']);
$this->smtp_conn = fsockopen(
$connection = fsockopen(
$host,
$port,
$errno,
@ -342,13 +408,14 @@ class SMTP
);
restore_error_handler();
}
// Verify we connected properly
if (!is_resource($this->smtp_conn)) {
//Verify we connected properly
if (!is_resource($connection)) {
$this->setError(
'Failed to connect to server',
'',
(string) $errno,
(string) $errstr
$errstr
);
$this->edebug(
'SMTP ERROR: ' . $this->error['error']
@ -358,22 +425,19 @@ class SMTP
return false;
}
$this->edebug('Connection: opened', self::DEBUG_CONNECTION);
// SMTP server can take longer to respond, give longer timeout for first read
// Windows does not have support for this timeout function
if (substr(PHP_OS, 0, 3) != 'WIN') {
$max = ini_get('max_execution_time');
// Don't bother if unlimited
if (0 != $max and $timeout > $max) {
//SMTP server can take longer to respond, give longer timeout for first read
//Windows does not have support for this timeout function
if (strpos(PHP_OS, 'WIN') !== 0) {
$max = (int)ini_get('max_execution_time');
//Don't bother if unlimited, or if set_time_limit is disabled
if (0 !== $max && $timeout > $max && strpos(ini_get('disable_functions'), 'set_time_limit') === false) {
@set_time_limit($timeout);
}
stream_set_timeout($this->smtp_conn, $timeout, 0);
stream_set_timeout($connection, $timeout, 0);
}
// Get any announcement
$announce = $this->get_lines();
$this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
return true;
return $connection;
}
/**
@ -397,7 +461,7 @@ class SMTP
$crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
}
// Begin encrypted connection
//Begin encrypted connection
set_error_handler([$this, 'errorHandler']);
$crypto_ok = stream_socket_enable_crypto(
$this->smtp_conn,
@ -435,23 +499,23 @@ class SMTP
}
if (array_key_exists('EHLO', $this->server_caps)) {
// SMTP extensions are available; try to find a proper authentication method
//SMTP extensions are available; try to find a proper authentication method
if (!array_key_exists('AUTH', $this->server_caps)) {
$this->setError('Authentication is not allowed at this stage');
// 'at this stage' means that auth may be allowed after the stage changes
// e.g. after STARTTLS
//'at this stage' means that auth may be allowed after the stage changes
//e.g. after STARTTLS
return false;
}
$this->edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNSPECIFIED'), self::DEBUG_LOWLEVEL);
$this->edebug('Auth method requested: ' . ($authtype ?: 'UNSPECIFIED'), self::DEBUG_LOWLEVEL);
$this->edebug(
'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
self::DEBUG_LOWLEVEL
);
//If we have requested a specific auth type, check the server supports it before trying others
if (null !== $authtype and !in_array($authtype, $this->server_caps['AUTH'])) {
if (null !== $authtype && !in_array($authtype, $this->server_caps['AUTH'], true)) {
$this->edebug('Requested auth method not available: ' . $authtype, self::DEBUG_LOWLEVEL);
$authtype = null;
}
@ -460,7 +524,7 @@ class SMTP
//If no auth mechanism is specified, attempt to use these, in this order
//Try CRAM-MD5 first as it's more secure than the others
foreach (['CRAM-MD5', 'LOGIN', 'PLAIN', 'XOAUTH2'] as $method) {
if (in_array($method, $this->server_caps['AUTH'])) {
if (in_array($method, $this->server_caps['AUTH'], true)) {
$authtype = $method;
break;
}
@ -470,10 +534,10 @@ class SMTP
return false;
}
self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
$this->edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
}
if (!in_array($authtype, $this->server_caps['AUTH'])) {
if (!in_array($authtype, $this->server_caps['AUTH'], true)) {
$this->setError("The requested authentication method \"$authtype\" is not supported by the server");
return false;
@ -483,12 +547,15 @@ class SMTP
}
switch ($authtype) {
case 'PLAIN':
// Start authentication
//Start authentication
if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) {
return false;
}
// Send encoded username and password
if (!$this->sendCommand(
//Send encoded username and password
if (
//Format from https://tools.ietf.org/html/rfc4616#section-2
//We skip the first field (it's forgery), so the string starts with a null byte
!$this->sendCommand(
'User & Password',
base64_encode("\0" . $username . "\0" . $password),
235
@ -498,7 +565,7 @@ class SMTP
}
break;
case 'LOGIN':
// Start authentication
//Start authentication
if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) {
return false;
}
@ -510,17 +577,17 @@ class SMTP
}
break;
case 'CRAM-MD5':
// Start authentication
//Start authentication
if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
return false;
}
// Get the challenge
//Get the challenge
$challenge = base64_decode(substr($this->last_reply, 4));
// Build the response
//Build the response
$response = $username . ' ' . $this->hmac($challenge, $password);
// send encoded credentials
//send encoded credentials
return $this->sendCommand('Username', base64_encode($response), 235);
case 'XOAUTH2':
//The OAuth instance must be set up prior to requesting auth.
@ -529,7 +596,7 @@ class SMTP
}
$oauth = $OAuth->getOauth64();
// Start authentication
//Start authentication
if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
return false;
}
@ -559,15 +626,15 @@ class SMTP
return hash_hmac('md5', $data, $key);
}
// The following borrowed from
// http://php.net/manual/en/function.mhash.php#27225
//The following borrowed from
//http://php.net/manual/en/function.mhash.php#27225
// RFC 2104 HMAC implementation for php.
// Creates an md5 HMAC.
// Eliminates the need to install mhash to compute a HMAC
// by Lance Rushing
//RFC 2104 HMAC implementation for php.
//Creates an md5 HMAC.
//Eliminates the need to install mhash to compute a HMAC
//by Lance Rushing
$bytelen = 64; // byte length for md5
$bytelen = 64; //byte length for md5
if (strlen($key) > $bytelen) {
$key = pack('H*', md5($key));
}
@ -590,7 +657,7 @@ class SMTP
if (is_resource($this->smtp_conn)) {
$sock_status = stream_get_meta_data($this->smtp_conn);
if ($sock_status['eof']) {
// The socket is valid but we are not connected
//The socket is valid but we are not connected
$this->edebug(
'SMTP NOTICE: EOF caught while checking if connected',
self::DEBUG_CLIENT
@ -600,7 +667,7 @@ class SMTP
return false;
}
return true; // everything looks good
return true; //everything looks good
}
return false;
@ -618,7 +685,7 @@ class SMTP
$this->server_caps = null;
$this->helo_rply = null;
if (is_resource($this->smtp_conn)) {
// close the connection and cleanup
//Close the connection and cleanup
fclose($this->smtp_conn);
$this->smtp_conn = null; //Makes for cleaner serialization
$this->edebug('Connection: closed', self::DEBUG_CONNECTION);
@ -653,7 +720,7 @@ class SMTP
* NOTE: this does not count towards line-length limit.
*/
// Normalize line breaks before exploding
//Normalize line breaks before exploding
$lines = explode("\n", str_replace(["\r\n", "\r"], "\n", $msg_data));
/* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
@ -663,13 +730,13 @@ class SMTP
$field = substr($lines[0], 0, strpos($lines[0], ':'));
$in_headers = false;
if (!empty($field) and strpos($field, ' ') === false) {
if (!empty($field) && strpos($field, ' ') === false) {
$in_headers = true;
}
foreach ($lines as $line) {
$lines_out = [];
if ($in_headers and $line == '') {
if ($in_headers && $line === '') {
$in_headers = false;
}
//Break this line up into several smaller lines if it's too long
@ -699,8 +766,9 @@ class SMTP
//Send the lines to the server
foreach ($lines_out as $line_out) {
//RFC2821 section 4.5.2
if (!empty($line_out) and $line_out[0] == '.') {
//Dot-stuffing as per RFC5321 section 4.5.2
//https://tools.ietf.org/html/rfc5321#section-4.5.2
if (!empty($line_out) && $line_out[0] === '.') {
$line_out = '.' . $line_out;
}
$this->client_send($line_out . static::LE, 'DATA');
@ -710,7 +778,7 @@ class SMTP
//Message data has been sent, complete the command
//Increase timelimit for end of DATA command
$savetimelimit = $this->Timelimit;
$this->Timelimit = $this->Timelimit * 2;
$this->Timelimit *= 2;
$result = $this->sendCommand('DATA END', '.', 250);
$this->recordLastTransactionID();
//Restore timelimit
@ -733,7 +801,16 @@ class SMTP
public function hello($host = '')
{
//Try extended hello first (RFC 2821)
return $this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host);
if ($this->sendHello('EHLO', $host)) {
return true;
}
//Some servers shut down the SMTP service here (RFC 5321)
if (substr($this->helo_rply, 0, 3) == '421') {
return false;
}
return $this->sendHello('HELO', $host);
}
/**
@ -838,7 +915,7 @@ class SMTP
{
$noerror = $this->sendCommand('QUIT', 'QUIT', 221);
$err = $this->error; //Save any error
if ($noerror or $close_on_error) {
if ($noerror || $close_on_error) {
$this->close();
$this->error = $err; //Restore any error from the quit command
}
@ -915,7 +992,7 @@ class SMTP
return false;
}
//Reject line breaks in all commands
if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) {
if ((strpos($commandstring, "\n") !== false) || (strpos($commandstring, "\r") !== false)) {
$this->setError("Command '$command' contained line breaks");
return false;
@ -923,12 +1000,12 @@ class SMTP
$this->client_send($commandstring . static::LE, $command);
$this->last_reply = $this->get_lines();
// Fetch SMTP code and possible error code explanation
//Fetch SMTP code and possible error code explanation
$matches = [];
if (preg_match('/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]{1,2}) )?/', $this->last_reply, $matches)) {
$code = $matches[1];
if (preg_match('/^([\d]{3})[ -](?:([\d]\\.[\d]\\.[\d]{1,2}) )?/', $this->last_reply, $matches)) {
$code = (int) $matches[1];
$code_ex = (count($matches) > 2 ? $matches[2] : null);
// Cut off error code from each response line
//Cut off error code from each response line
$detail = preg_replace(
"/{$code}[ -]" .
($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . '/m',
@ -936,15 +1013,15 @@ class SMTP
$this->last_reply
);
} else {
// Fall back to simple parsing if regex fails
$code = substr($this->last_reply, 0, 3);
//Fall back to simple parsing if regex fails
$code = (int) substr($this->last_reply, 0, 3);
$code_ex = null;
$detail = substr($this->last_reply, 4);
}
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
if (!in_array($code, (array) $expect)) {
if (!in_array($code, (array) $expect, true)) {
$this->setError(
"$command command failed",
$detail,
@ -1035,9 +1112,11 @@ 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 and
in_array($command, ['User & Password', 'Username', 'Password'], true)) {
$this->edebug('CLIENT -> SERVER: <credentials hidden>', self::DEBUG_CLIENT);
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);
}
@ -1083,7 +1162,7 @@ class SMTP
*
* @param string $name Name of SMTP extension or 'HELO'|'EHLO'
*
* @return mixed
* @return string|bool|null
*/
public function getServerExt($name)
{
@ -1094,10 +1173,10 @@ class SMTP
}
if (!array_key_exists($name, $this->server_caps)) {
if ('HELO' == $name) {
if ('HELO' === $name) {
return $this->server_caps['EHLO'];
}
if ('EHLO' == $name || array_key_exists('EHLO', $this->server_caps)) {
if ('EHLO' === $name || array_key_exists('EHLO', $this->server_caps)) {
return false;
}
$this->setError('HELO handshake was used; No information about server extensions available');
@ -1129,7 +1208,7 @@ class SMTP
*/
protected function get_lines()
{
// If the connection is bad, give up straight away
//If the connection is bad, give up straight away
if (!is_resource($this->smtp_conn)) {
return '';
}
@ -1141,36 +1220,64 @@ class SMTP
}
$selR = [$this->smtp_conn];
$selW = null;
while (is_resource($this->smtp_conn) and !feof($this->smtp_conn)) {
while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
//Must pass vars in here as params are by reference
if (!stream_select($selR, $selW, $selW, $this->Timelimit)) {
//solution for signals inspired by https://github.com/symfony/symfony/pull/6540
set_error_handler([$this, 'errorHandler']);
$n = stream_select($selR, $selW, $selW, $this->Timelimit);
restore_error_handler();
if ($n === false) {
$message = $this->getError()['detail'];
$this->edebug(
'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
'SMTP -> get_lines(): select failed (' . $message . ')',
self::DEBUG_LOWLEVEL
);
//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',
self::DEBUG_LOWLEVEL
);
$this->setError('');
continue;
}
break;
}
if (!$n) {
$this->edebug(
'SMTP -> get_lines(): select timed-out in (' . $this->Timelimit . ' sec)',
self::DEBUG_LOWLEVEL
);
break;
}
//Deliberate noise suppression - errors are handled afterwards
$str = @fgets($this->smtp_conn, 515);
$str = @fgets($this->smtp_conn, self::MAX_REPLY_LENGTH);
$this->edebug('SMTP INBOUND: "' . trim($str) . '"', self::DEBUG_LOWLEVEL);
$data .= $str;
// If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
// or 4th character is a space, we are done reading, break the loop,
// string array access is a micro-optimisation over strlen
if (!isset($str[3]) or (isset($str[3]) and $str[3] == ' ')) {
//If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
//or 4th character is a space or a line break char, we are done reading, break the loop.
//String array access is a significant micro-optimisation over strlen
if (!isset($str[3]) || $str[3] === ' ' || $str[3] === "\r" || $str[3] === "\n") {
break;
}
// Timed-out? Log and break
//Timed-out? Log and break
$info = stream_get_meta_data($this->smtp_conn);
if ($info['timed_out']) {
$this->edebug(
'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
'SMTP -> get_lines(): stream timed-out (' . $this->Timeout . ' sec)',
self::DEBUG_LOWLEVEL
);
break;
}
// Now check if reads took too long
if ($endtime and time() > $endtime) {
//Now check if reads took too long
if ($endtime && time() > $endtime) {
$this->edebug(
'SMTP -> get_lines(): timelimit reached (' .
$this->Timelimit . ' sec)',
@ -1321,6 +1428,7 @@ class SMTP
} else {
$this->last_smtp_transaction_id = false;
foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
$matches = [];
if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
$this->last_smtp_transaction_id = trim($matches[1]);
break;

Binary file not shown.

Binary file not shown.