Commit ac8215a1 authored by Balint Pekker's avatar Balint Pekker Committed by Jakob P
Browse files

Issue #3298110 by balintpekker, japerry: Automated Drupal 10 compatibility fixes

parent 9de1cc18
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
    "issues": "https://www.drupal.org/project/issues/smtp"
  },
  "require": {
    "drupal/core": "^8.8 || ^9",
    "drupal/core": "^8.8 || ^9 || ^10",
    "phpmailer/phpmailer": "^6.1.7"
  },
  "extra": {
+1 −1
Original line number Diff line number Diff line
@@ -2,5 +2,5 @@ name: SMTP Authentication Support
description: "Allow for site emails to be sent through an SMTP server of your choice."
package: Mail
type: module
core_version_requirement: ^8.8 || ^9
core_version_requirement: ^9.2 || ^10
configure: smtp.config
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ class ConnectionTester {
        $this->value = $this->t('SMTP module is enabled, turned on, and connection is valid.');
        return TRUE;
      }
      $this->severity = REQUIREMENT_ERROR;
      $this->severity = self::REQUIREMENT_ERROR;
      $this->value = $this->t('SMTP module is enabled, turned on, but SmtpConnect() returned FALSE.');
      return FALSE;
    }
+9 −8
Original line number Diff line number Diff line
@@ -2,8 +2,9 @@

namespace Drupal\smtp\Plugin\Mail;

use Symfony\Component\Mime\Header\UnstructuredHeader;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
use Drupal\Component\Utility\EmailValidatorInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Mail\MailFormatHelper;
@@ -15,7 +16,6 @@ use PHPMailer\PHPMailer\PHPMailer;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;

/**
 * Modify the drupal mail system to use smtp when sending emails.
@@ -80,7 +80,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {
  /**
   * The file mime type guesser service.
   *
   * @var \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface
   * @var \Symfony\Component\Mime\MimeTypeGuesserInterface
   */
  protected $mimeTypeGuesser;

@@ -112,7 +112,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {
   *   The current user service.
   * @param \Drupal\Core\File\FileSystemInterface $file_system
   *   The file system service.
   * @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser
   * @param \Symfony\Component\Mime\MimeTypeGuesserInterface $mime_type_guesser
   *   The file mime type guesser service.
   */
  public function __construct(array $configuration,
@@ -216,7 +216,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {
    $subject = $message['subject'];

    // Optionally reroute all emails to a single address.
    list($to, $headers) = $this->applyRerouting($to, $headers);
    [$to, $headers] = $this->applyRerouting($to, $headers);

    $mailer = $this->getMailer();
    // Use email.validator due to different validation standard by PHPMailer.
@@ -255,6 +255,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {
      $from_name = $this->configFactory->get('system.site')->get('name');
    }

    $smtpFrom = $this->smtpConfig->get('smtp_from');
    // Set from email.
    if (!empty($message['params']['from_mail'])) {
      $from = $message['params']['from_mail'];
@@ -292,7 +293,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {

    // Defines the From value to what we expect.
    $mailer->From = $from;
    $mailer->FromName = Unicode::mimeHeaderEncode($from_name);
    $mailer->FromName = (new UnstructuredHeader('From', $from_name))->getBodyAsString();
    $mailer->Sender = $from;

    $hostname = $this->smtpConfig->get('smtp_client_hostname');
@@ -457,7 +458,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {
          $bcc_recipients = explode(',', $value);
          foreach ($bcc_recipients as $bcc_recipient) {
            $bcc_comp = $this->getComponents($bcc_recipient);
            $mailer->AddBCC($bcc_comp['email'], Unicode::mimeHeaderEncode($bcc_comp['name']));
            $mailer->AddBCC($bcc_comp['email'], (new UnstructuredHeader('BCC', $bcc_comp['name']))->getBodyAsString());
          }
          break;

@@ -620,7 +621,7 @@ class SMTPMailSystem implements MailInterface, ContainerFactoryPluginInterface {
              }

              $attachment_new_filename = $this->fileSystem->tempnam('temporary://', 'smtp');
              $file_path = file_save_data($attachment, $attachment_new_filename, FileSystemInterface::EXISTS_REPLACE);
              $file_path = \Drupal::service('file.repository')->writeData($attachment, $attachment_new_filename, FileSystemInterface::EXISTS_REPLACE);
              $real_path = $this->fileSystem->realpath($file_path->uri);

              if (!$mailer->addStringAttachment(file_get_contents($real_path), $file_name)) {
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ use PHPMailer\PHPMailer\PHPMailer;
 */
class ConnectionTesterTest extends KernelTestBase {

  public static $modules = [
  protected static $modules = [
    'smtp',
  ];

Loading