diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e0bbfd50..a67e07ee 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,9 @@ -Before submitting your pull request, check whether your code adheres to PHPMailer -coding standards by running the following command: +Before submitting your pull request, check whether your code adheres to PHPMailer coding standards (which is mostly [PSR-12](https://www.php-fig.org/psr/psr-12/)) by running [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer): -`./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix ` + ./vendor/bin/phpcs -And committing eventual changes. It's important that this command uses the specific version of php-cs-fixer configured for PHPMailer, so run `composer install` within the PHPMailer folder to use the exact version it needs. +Any problems reported can probably be fixed automatically by using its partner tool, PHP code beautifier: + + ./vendor/bin/phpcbf + +It's important that this command uses the specific version of phpcs configured for PHPMailer, so run `composer install` within the PHPMailer folder to use the exact version it needs. diff --git a/.gitignore b/.gitignore index 33110b4a..4719a995 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ build/ vendor/ *.pem composer.lock -.php_cs.cache diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 3bf20468..00000000 --- a/.php_cs +++ /dev/null @@ -1,35 +0,0 @@ -setRiskyAllowed(true) - ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - 'array_syntax' => ['syntax' => 'short'], - 'binary_operator_spaces' => false, - 'concat_space' => ['spacing' => 'one'], - 'heredoc_to_nowdoc' => true, - 'method_argument_space' => true, - 'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'], - 'no_php4_constructor' => true, - 'no_short_echo_tag' => true, - 'no_unreachable_default_argument_value' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_imports' => true, - 'php_unit_fqcn_annotation' => false, - 'phpdoc_add_missing_param_annotation' => true, - 'phpdoc_order' => true, - 'phpdoc_summary' => false, - 'semicolon_after_instruction' => true, - 'simplified_null_return' => true, - 'native_function_invocation' => false, - 'yoda_style' => false, - 'no_break_comment' => false, - 'native_constant_invocation' => false, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__ . '/src') - ->in(__DIR__ . '/test') - ) -; diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 95162c3b..45dd3bcb 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,6 +1,6 @@ build: environment: - php: '5.6.0' + php: '7.4.0' before_commands: - "composer install --prefer-source" @@ -49,19 +49,6 @@ tools: - test - vendor - # PHP CS Fixer (http://http://cs.sensiolabs.org/). - php_cs_fixer: - enabled: true - config: - level: psr2 - filter: - excluded_paths: - - 'docs/*' - - 'examples/*' - - 'extras/*' - - 'test/*' - - 'vendor/*' - # Analyzes the size and structure of a PHP project. php_loc: enabled: true diff --git a/.travis.yml b/.travis.yml index b3a02a32..b2fc8d33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ before_install: - sudo apt-get install -y -qq postfix install: - - REMOVE_PACKAGE="friendsofphp/php-cs-fixer"; if [ "$CS_CHECK" = 1 ]; then REMOVE_PACKAGE="phpunit/phpunit"; fi; composer remove --no-update --no-scripts --dev $REMOVE_PACKAGE - composer install - if [ "$CODE_COVERAGE" != 1 ]; then phpenv config-rm xdebug.ini || true; fi @@ -23,12 +22,7 @@ before_script: - sudo mkdir -p /var/qmail/bin - sudo cp test/fakesendmail.sh /var/qmail/bin/sendmail - sudo cp test/fakesendmail.sh /usr/sbin/sendmail - - | - if [[ $TRAVIS_PHP_VERSION = "hhv"* ]]; then - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' >> /etc/hhvm/php.ini - else - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini - fi + - echo 'sendmail_path = "/usr/sbin/sendmail -t -i "' > $(php --ini|grep -m 1 "ini files in:"|cut -d ":" -f 2)/sendmail.ini script: ./vendor/bin/phpunit --configuration ./travis.phpunit.xml.dist @@ -43,12 +37,8 @@ stages: jobs: include: - stage: coding-standard - before_install: - before_script: - script: ./vendor/bin/php-cs-fixer --diff --dry-run --verbose fix - after_script: - php: 5.6 - env: CS_CHECK=1 + script: ./vendor/bin/phpcs -s + php: 7.4 - stage: test - php: 7.0 - php: 7.1 @@ -57,10 +47,8 @@ jobs: - php: 7.4 env: CODE_COVERAGE=1 - php: nightly - - php: hhvm dist: trusty matrix: allow_failures: - php: nightly - - php: hhvm diff --git a/composer.json b/composer.json index 95a89919..37e01e3d 100644 --- a/composer.json +++ b/composer.json @@ -32,9 +32,12 @@ "ext-hash": "*" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.2", + "squizlabs/php_codesniffer": "3.5.6", + "phpcompatibility/php-compatibility": "9.3.5", "phpunit/phpunit": "^4.8 || ^5.7", - "doctrine/annotations": "^1.2" + "doctrine/annotations": "^1.2", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "roave/security-advisories": "dev-latest" }, "suggest": { "psr/log": "For optional PSR-3 debug logging", diff --git a/examples/DKIM_gen_keys.phps b/examples/DKIM_gen_keys.phps index 42cbc952..5e4aeca6 100644 --- a/examples/DKIM_gen_keys.phps +++ b/examples/DKIM_gen_keys.phps @@ -1,4 +1,5 @@ setFrom('from@example.com', 'First Last'); $mail->addAddress('whoto@example.com', 'John Doe'); $mail->Subject = 'PHPMailer mail() test'; @@ -39,7 +40,7 @@ $mail->DKIM_extraHeaders = ['List-Unsubscribe', 'List-Help']; //When you send, the DKIM settings will be used to sign the message if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; } diff --git a/examples/callback.phps b/examples/callback.phps index 32165f73..06411fb4 100644 --- a/examples/callback.phps +++ b/examples/callback.phps @@ -1,4 +1,5 @@ isMail(); diff --git a/examples/contactform-ajax.phps b/examples/contactform-ajax.phps index 6f582644..373124f9 100644 --- a/examples/contactform-ajax.phps +++ b/examples/contactform-ajax.phps @@ -1,4 +1,5 @@ send()) { //The reason for failing to send will be in $mail->ErrorInfo //but it's unsafe to display errors directly to users - process the error, log it on your server. - if ($isAjax) + if ($isAjax) { http_response_code(500); + } $response = [ "status" => false, @@ -93,7 +96,9 @@ EOT;

Contact us

-

+



diff --git a/examples/contactform.phps b/examples/contactform.phps index 92a6f9ea..9f367735 100644 --- a/examples/contactform.phps +++ b/examples/contactform.phps @@ -1,4 +1,5 @@ Subject = '[Yay for me!] ' . $this->Subject; $r = parent::send(); - echo 'I sent a message with subject '. $this->Subject; + echo 'I sent a message with subject ' . $this->Subject; return $r; } @@ -67,5 +68,5 @@ try { $mail->send(); //no need to check for errors - the exception handler will do it } catch (Exception $e) { //Note that this is catching the PHPMailer Exception class, not the global \Exception type! - echo 'Caught a '. get_class($e) .': '. $e->getMessage(); + echo 'Caught a ' . get_class($e) . ': ' . $e->getMessage(); } diff --git a/examples/gmail.phps b/examples/gmail.phps index a259a72b..508a04df 100644 --- a/examples/gmail.phps +++ b/examples/gmail.phps @@ -1,4 +1,5 @@ isSMTP(); @@ -69,7 +70,7 @@ $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; //Section 2: IMAP diff --git a/examples/gmail_xoauth.phps b/examples/gmail_xoauth.phps index 76983633..3851f992 100644 --- a/examples/gmail_xoauth.phps +++ b/examples/gmail_xoauth.phps @@ -1,4 +1,5 @@ isSMTP(); @@ -100,7 +100,7 @@ $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; } diff --git a/examples/mail.phps b/examples/mail.phps index bc187b40..ebb9976a 100644 --- a/examples/mail.phps +++ b/examples/mail.phps @@ -1,4 +1,5 @@ setFrom('from@example.com', 'First Last'); //Set an alternative reply-to address @@ -28,7 +29,7 @@ $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; } diff --git a/examples/mailing_list.phps b/examples/mailing_list.phps index 57abdfdd..e05cad59 100644 --- a/examples/mailing_list.phps +++ b/examples/mailing_list.phps @@ -1,4 +1,5 @@ send(); - echo 'Message sent to :' . htmlspecialchars($row['full_name']) . ' (' . htmlspecialchars($row['email']) . ')
'; + echo 'Message sent to :' . htmlspecialchars($row['full_name']) . ' (' . + htmlspecialchars($row['email']) . ')
'; //Mark it as sent in the DB mysqli_query( $mysql, diff --git a/examples/pop_before_smtp.phps b/examples/pop_before_smtp.phps index 31d7876a..f9644532 100644 --- a/examples/pop_before_smtp.phps +++ b/examples/pop_before_smtp.phps @@ -1,4 +1,5 @@ setFrom('from@example.com', 'First Last'); $mail->addAddress('whoto@example.com', 'John Doe'); $mail->Subject = 'PHPMailer file sender'; @@ -26,7 +27,7 @@ if (array_key_exists('userfile', $_FILES)) { $msg .= 'Failed to attach file ' . $_FILES['userfile']['name']; } if (!$mail->send()) { - $msg .= 'Mailer Error: '. $mail->ErrorInfo; + $msg .= 'Mailer Error: ' . $mail->ErrorInfo; } else { $msg .= 'Message sent!'; } diff --git a/examples/send_multiple_file_upload.phps b/examples/send_multiple_file_upload.phps index 714dc0d9..15fadd82 100644 --- a/examples/send_multiple_file_upload.phps +++ b/examples/send_multiple_file_upload.phps @@ -1,4 +1,5 @@ setFrom('from@example.com', 'First Last'); $mail->addAddress('whoto@example.com', 'John Doe'); $mail->Subject = 'PHPMailer file sender'; @@ -28,7 +29,7 @@ if (array_key_exists('userfile', $_FILES)) { } } if (!$mail->send()) { - $msg .= 'Mailer Error: '. $mail->ErrorInfo; + $msg .= 'Mailer Error: ' . $mail->ErrorInfo; } else { $msg .= 'Message sent!'; } diff --git a/examples/sendmail.phps b/examples/sendmail.phps index 4b06e607..3cc6d967 100644 --- a/examples/sendmail.phps +++ b/examples/sendmail.phps @@ -1,4 +1,5 @@ isSendmail(); //Set who the message is to be sent from @@ -30,7 +31,7 @@ $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; } diff --git a/examples/simple_contact_form.phps b/examples/simple_contact_form.phps index f14eaa12..2915c9b9 100644 --- a/examples/simple_contact_form.phps +++ b/examples/simple_contact_form.phps @@ -1,4 +1,5 @@ isSMTP(); $mail->Host = 'localhost'; $mail->Port = 25; @@ -65,7 +66,7 @@ if (array_key_exists('to', $_POST)) { $mail->Subject = 'Contact form: ' . $subject; $mail->Body = "Contact form submission\n\n" . $query; if (!$mail->send()) { - $msg .= 'Mailer Error: '. $mail->ErrorInfo; + $msg .= 'Mailer Error: ' . $mail->ErrorInfo; } else { $msg .= 'Message sent!'; } diff --git a/examples/smime_signed_mail.phps b/examples/smime_signed_mail.phps index 394edc90..7ddc2bef 100644 --- a/examples/smime_signed_mail.phps +++ b/examples/smime_signed_mail.phps @@ -1,4 +1,5 @@ sign( //Send the message, check for errors if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; } diff --git a/examples/smtp.phps b/examples/smtp.phps index 97a42d3a..de8adc30 100644 --- a/examples/smtp.phps +++ b/examples/smtp.phps @@ -1,4 +1,5 @@ isSMTP(); //Enable SMTP debugging diff --git a/examples/smtp_check.phps b/examples/smtp_check.phps index 8058e3c0..be9347c1 100644 --- a/examples/smtp_check.phps +++ b/examples/smtp_check.phps @@ -1,4 +1,5 @@ do_debug = SMTP::DEBUG_CONNECTION; diff --git a/examples/smtp_low_memory.phps b/examples/smtp_low_memory.phps index 7b7f685e..d9080675 100644 --- a/examples/smtp_low_memory.phps +++ b/examples/smtp_low_memory.phps @@ -1,4 +1,5 @@ smtp)) { - $this->smtp = new SMTPLowMemory; + $this->smtp = new SMTPLowMemory(); } return $this->smtp; diff --git a/examples/smtp_no_auth.phps b/examples/smtp_no_auth.phps index d2178a70..5333f098 100644 --- a/examples/smtp_no_auth.phps +++ b/examples/smtp_no_auth.phps @@ -1,4 +1,5 @@ isSMTP(); //Enable SMTP debugging @@ -46,7 +47,7 @@ $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { - echo 'Mailer Error: '. $mail->ErrorInfo; + echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message sent!'; } diff --git a/examples/ssl_options.phps b/examples/ssl_options.phps index 6c697155..a64b8444 100644 --- a/examples/ssl_options.phps +++ b/examples/ssl_options.phps @@ -1,4 +1,5 @@ isSMTP(); diff --git a/language/phpmailer.lang-af.php b/language/phpmailer.lang-af.php index 3c42d78e..0b2a72d5 100644 --- a/language/phpmailer.lang-af.php +++ b/language/phpmailer.lang-af.php @@ -1,4 +1,5 @@ - * Rewrite and extension of the work by Mikael Stokkebro - * + * Rewrite and extension of the work by Mikael Stokkebro + * */ $PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Login mislykkedes.'; diff --git a/language/phpmailer.lang-de.php b/language/phpmailer.lang-de.php index b36c6cbd..e7e59d2b 100644 --- a/language/phpmailer.lang-de.php +++ b/language/phpmailer.lang-de.php @@ -1,4 +1,5 @@ */ + $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.'; diff --git a/language/phpmailer.lang-ms.php b/language/phpmailer.lang-ms.php index f12a6ad4..71db3383 100644 --- a/language/phpmailer.lang-ms.php +++ b/language/phpmailer.lang-ms.php @@ -1,4 +1,5 @@ + + + + + + + + + + + + + src + test + examples + language + + + + + + + + + + + + + + + + + + + + diff --git a/src/Exception.php b/src/Exception.php index e7807fc2..a50a8991 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -1,4 +1,5 @@ host) && static::validateAddress( - $address->mailbox . '@' . $address->host - )) { + if ( + ('.SYNTAX-ERROR.' !== $address->host) && static::validateAddress( + $address->mailbox . '@' . $address->host + ) + ) { $addresses[] = [ 'name' => (property_exists($address, 'personal') ? $address->personal : ''), 'address' => $address->mailbox . '@' . $address->host, @@ -1241,7 +1244,8 @@ class PHPMailer $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim // Don't validate now addresses with IDN. Will be done in send(). $pos = strrpos($address, '@'); - if ((false === $pos) + if ( + (false === $pos) || ((!$this->has8bitChars(substr($address, ++$pos)) || !static::idnSupported()) && !static::validateAddress($address)) ) { @@ -1393,7 +1397,8 @@ class PHPMailer { // Verify we have required functions, CharSet, and at-sign. $pos = strrpos($address, '@'); - if (!empty($this->CharSet) && + if ( + !empty($this->CharSet) && false !== $pos && static::idnSupported() ) { @@ -1455,7 +1460,8 @@ class PHPMailer */ public function preSend() { - if ('smtp' === $this->Mailer + if ( + 'smtp' === $this->Mailer || ('mail' === $this->Mailer && stripos(PHP_OS, 'WIN') === 0) ) { //SMTP mandates RFC-compliant line endings @@ -1466,7 +1472,8 @@ class PHPMailer static::setLE(PHP_EOL); } //Check for buggy PHP versions that add a header with an incorrect line break - if ('mail' === $this->Mailer + if ( + 'mail' === $this->Mailer && ((PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70017) || (PHP_VERSION_ID >= 70100 && PHP_VERSION_ID < 70103)) && ini_get('mail.add_x_header') === '1' @@ -1553,7 +1560,8 @@ class PHPMailer } // Sign with DKIM if enabled - if (!empty($this->DKIM_domain) + if ( + !empty($this->DKIM_domain) && !empty($this->DKIM_selector) && (!empty($this->DKIM_private_string) || (!empty($this->DKIM_private) @@ -1611,7 +1619,7 @@ class PHPMailer } } catch (Exception $exc) { if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) { - $this->smtp->reset(); + $this->smtp->reset(); } $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); @@ -1717,7 +1725,8 @@ class PHPMailer protected static function isShellSafe($string) { // Future-proof - if (escapeshellcmd($string) !== $string + if ( + escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), ["'$string'", "\"$string\""]) ) { return false; @@ -1901,7 +1910,7 @@ class PHPMailer $isSent = true; } - $callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]]; + $callbacks[] = ['issent' => $isSent, 'to' => $to[0]]; } } @@ -1981,11 +1990,13 @@ class PHPMailer foreach ($hosts as $hostentry) { $hostinfo = []; - if (!preg_match( - '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', - trim($hostentry), - $hostinfo - )) { + if ( + !preg_match( + '/^(?:(ssl|tls):\/\/)?(.+?)(?::(\d+))?$/', + trim($hostentry), + $hostinfo + ) + ) { $this->edebug($this->lang('invalid_hostentry') . ' ' . trim($hostentry)); // Not a valid host entry continue; @@ -2054,12 +2065,14 @@ class PHPMailer // We must resend EHLO after TLS negotiation $this->smtp->hello($hello); } - if ($this->SMTPAuth && !$this->smtp->authenticate( - $this->Username, - $this->Password, - $this->AuthType, - $this->oauth - )) { + if ( + $this->SMTPAuth && !$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->oauth + ) + ) { throw new Exception($this->lang('authenticate')); } @@ -2426,7 +2439,8 @@ class PHPMailer } // sendmail and mail() extract Bcc from the header before sending - if (( + if ( + ( 'sendmail' === $this->Mailer || 'qmail' === $this->Mailer || 'mail' === $this->Mailer ) && count($this->bcc) > 0 @@ -3896,7 +3910,8 @@ class PHPMailer public static function isValidHost($host) { //Simple syntax limits - if (empty($host) + if ( + empty($host) || !is_string($host) || strlen($host) > 256 || !preg_match('/^([a-zA-Z\d.-]*|\[[a-fA-F\d:]+])$/', $host) @@ -4062,7 +4077,8 @@ class PHPMailer ); continue; } - if (// Only process relative URLs if a basedir is provided (i.e. no absolute local paths) + if ( +// Only process relative URLs if a basedir is provided (i.e. no absolute local paths) !empty($basedir) // Ignore URLs containing parent dir traversal (..) && (strpos($url, '..') === false) @@ -4084,13 +4100,14 @@ class PHPMailer if (strlen($directory) > 1 && '/' !== substr($directory, -1)) { $directory .= '/'; } - if ($this->addEmbeddedImage( - $basedir . $directory . $filename, - $cid, - $filename, - static::ENCODING_BASE64, - static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)) - ) + if ( + $this->addEmbeddedImage( + $basedir . $directory . $filename, + $cid, + $filename, + static::ENCODING_BASE64, + static::_mime_types((string) static::mb_pathinfo($filename, PATHINFO_EXTENSION)) + ) ) { $message = preg_replace( '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', diff --git a/src/POP3.php b/src/POP3.php index a6a41284..95a32614 100644 --- a/src/POP3.php +++ b/src/POP3.php @@ -1,4 +1,5 @@ sendCommand( - 'User & Password', - base64_encode("\0" . $username . "\0" . $password), - 235 - ) + if ( + !$this->sendCommand( + 'User & Password', + base64_encode("\0" . $username . "\0" . $password), + 235 + ) ) { return false; } @@ -1086,8 +1088,10 @@ class SMTP { //If SMTP transcripts are left enabled, or debug output is posted online //it can leak credentials, so hide credentials in all but lowest level - if (self::DEBUG_LOWLEVEL > $this->do_debug && - in_array($command, ['User & Password', 'Username', 'Password'], true)) { + if ( + self::DEBUG_LOWLEVEL > $this->do_debug && + in_array($command, ['User & Password', 'Username', 'Password'], true) + ) { $this->edebug('CLIENT -> SERVER: [credentials hidden]', self::DEBUG_CLIENT); } else { $this->edebug('CLIENT -> SERVER: ' . $data, self::DEBUG_CLIENT); @@ -1207,7 +1211,8 @@ class SMTP self::DEBUG_LOWLEVEL ); - //stream_select returns false when the `select` system call is interrupted by an incoming signal, try the select again + //stream_select returns false when the `select` system call is interrupted + //by an incoming signal, try the select again if (stripos($message, 'interrupted system call') !== false) { $this->edebug( 'SMTP -> get_lines(): retrying stream_select', diff --git a/test/DebugLogTestListener.php b/test/DebugLogTestListener.php index 6d67fa3d..427e2526 100644 --- a/test/DebugLogTestListener.php +++ b/test/DebugLogTestListener.php @@ -1,4 +1,5 @@ Mail->isHTML(true); $this->Mail->CharSet = 'UTF-8'; - if (!$this->Mail->addAttachment( - realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'), - 'phpmailer_mini.png' - ) + if ( + !$this->Mail->addAttachment( + realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'), + 'phpmailer_mini.png' + ) ) { self::assertTrue(false, $this->Mail->ErrorInfo); @@ -1311,14 +1313,16 @@ EOT; $this->Mail->Subject .= ': HTML + unnamed embedded image'; $this->Mail->isHTML(true); - if (!$this->Mail->addStringEmbeddedImage( - file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')), - hash('sha256', 'phpmailer_mini.png') . '@phpmailer.0', - '', //Intentionally empty name - 'base64', - '', //Intentionally empty MIME type - 'inline' - )) { + if ( + !$this->Mail->addStringEmbeddedImage( + file_get_contents(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png')), + hash('sha256', 'phpmailer_mini.png') . '@phpmailer.0', + '', //Intentionally empty name + 'base64', + '', //Intentionally empty MIME type + 'inline' + ) + ) { self::assertTrue(false, $this->Mail->ErrorInfo); return; @@ -1337,20 +1341,22 @@ EOT; $this->Mail->Subject .= ': HTML + multiple Attachment'; $this->Mail->isHTML(true); - if (!$this->Mail->addAttachment( - realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'), - 'phpmailer_mini.png' - ) + if ( + !$this->Mail->addAttachment( + realpath($this->INCLUDE_DIR . '/examples/images/phpmailer_mini.png'), + 'phpmailer_mini.png' + ) ) { self::assertTrue(false, $this->Mail->ErrorInfo); return; } - if (!$this->Mail->addAttachment( - realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), - 'phpmailer.png' - ) + if ( + !$this->Mail->addAttachment( + realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), + 'phpmailer.png' + ) ) { self::assertTrue(false, $this->Mail->ErrorInfo); @@ -1372,13 +1378,14 @@ EOT; $this->Mail->Subject .= ': Embedded Image'; $this->Mail->isHTML(true); - if (!$this->Mail->addEmbeddedImage( - realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), - 'my-attach', - 'phpmailer.png', - 'base64', - 'image/png' - ) + if ( + !$this->Mail->addEmbeddedImage( + realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), + 'my-attach', + 'phpmailer.png', + 'base64', + 'image/png' + ) ) { self::assertTrue(false, $this->Mail->ErrorInfo); @@ -1420,13 +1427,14 @@ EOT; $this->Mail->Subject .= ': Embedded Image + Attachment'; $this->Mail->isHTML(true); - if (!$this->Mail->addEmbeddedImage( - realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), - 'my-attach', - 'phpmailer.png', - 'base64', - 'image/png' - ) + if ( + !$this->Mail->addEmbeddedImage( + realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), + 'my-attach', + 'phpmailer.png', + 'base64', + 'image/png' + ) ) { self::assertTrue(false, $this->Mail->ErrorInfo); @@ -2805,7 +2813,8 @@ EOT; // $this->Mail->smtpClose(); // All these hosts are expected to fail - // $this->Mail->Host = 'xyz://bogus:25;tls://[bogus]:25;ssl://localhost:12345;tls://localhost:587;10.10.10.10:54321;localhost:12345;10.10.10.10'. $_REQUEST['mail_host'].' '; + // $this->Mail->Host = 'xyz://bogus:25;tls://[bogus]:25;ssl://localhost:12345; + // tls://localhost:587;10.10.10.10:54321;localhost:12345;10.10.10.10'. $_REQUEST['mail_host'].' '; // self::assertFalse($this->Mail->smtpConnect()); // $this->Mail->smtpClose(); @@ -2836,7 +2845,7 @@ EOT; $property->setValue($PHPMailer, true); self::assertTrue($PHPMailer->getOAuth()); - $options =[ + $options = [ 'provider' => 'dummyprovider', 'userName' => 'dummyusername', 'clientSecret' => 'dummyclientsecret', diff --git a/test/bootstrap.php b/test/bootstrap.php index bff07b9f..23b46b4b 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,7 +1,9 @@