From ecc6fc0bb5c78d36b9b1cafe9d37d1559f5a027d Mon Sep 17 00:00:00 2001 From: vgreb Date: Wed, 10 Jun 2026 18:38:46 +0200 Subject: [PATCH 1/4] Suppression de l'adaptateur legacy PhpMailer --- app/config/services.yml | 5 ---- sources/Afup/Utils/Mail.php | 27 ------------------- sources/Afup/Utils/Mailing.php | 22 --------------- .../AppBundle/Accounting/InvoicingMailer.php | 6 +++-- 4 files changed, 4 insertions(+), 56 deletions(-) delete mode 100644 sources/Afup/Utils/Mail.php delete mode 100644 sources/Afup/Utils/Mailing.php diff --git a/app/config/services.yml b/app/config/services.yml index e9a4e8e6f..1a5734a81 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -125,11 +125,6 @@ services: $mailchimp: '@app.mailchimp_api' $listId: "%mailchimp_members_list%" - mailer.adapter.php: - class: AppBundle\Email\Mailer\Adapter\PhpMailerAdapter - factory: [AppBundle\Email\Mailer\Adapter\PhpMailerAdapter, createFromConfiguration] - arguments: ['@Afup\Site\Utils\Configuration'] - mailer.adapter.symfony: class: AppBundle\Email\Mailer\Adapter\SymfonyMailerAdapter autowire: true diff --git a/sources/Afup/Utils/Mail.php b/sources/Afup/Utils/Mail.php deleted file mode 100644 index c9c6017c5..000000000 --- a/sources/Afup/Utils/Mail.php +++ /dev/null @@ -1,27 +0,0 @@ -getRecipients(); - $recipient = reset($recipients); - $message->setContent(str_replace('$EMAIL$', $recipient->getEmail(), $body)); - - return Mail::createMailer()->send($message); - } -} diff --git a/sources/AppBundle/Accounting/InvoicingMailer.php b/sources/AppBundle/Accounting/InvoicingMailer.php index fbee75835..3bdb46dc9 100644 --- a/sources/AppBundle/Accounting/InvoicingMailer.php +++ b/sources/AppBundle/Accounting/InvoicingMailer.php @@ -4,10 +4,10 @@ namespace AppBundle\Accounting; -use Afup\Site\Utils\Mailing; use AppBundle\Afup; use AppBundle\Accounting\Model\Invoicing; use AppBundle\Email\Mailer\Attachment; +use AppBundle\Email\Mailer\Mailer; use AppBundle\Email\Mailer\MailUser; use AppBundle\Email\Mailer\Message; use Symfony\Component\DependencyInjection\Attribute\Autowire; @@ -16,6 +16,7 @@ { public function __construct( private InvoicingPdfGenerator $pdfGenerator, + private Mailer $mailer, #[Autowire('%kernel.project_dir%/../htdocs/cache/')] private string $publicCacheDir, ) {} @@ -48,7 +49,8 @@ public function sendInvoice(Invoicing $invoicing): bool 'base64', 'application/pdf', )); - $ok = Mailing::envoyerMail($message, $corps); + $message->setContent($corps); + $ok = $this->mailer->send($message); @unlink($cheminFacture); From 016f90ae769526dfd1c42cd3e6571ddbd6153910 Mon Sep 17 00:00:00 2001 From: vgreb Date: Wed, 10 Jun 2026 18:38:55 +0200 Subject: [PATCH 2/4] Suppression de PhpMailerAdapter --- .../Email/Mailer/Adapter/PhpMailerAdapter.php | 90 ------------------- 1 file changed, 90 deletions(-) delete mode 100644 sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php diff --git a/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php b/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php deleted file mode 100644 index 3510c7b66..000000000 --- a/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php +++ /dev/null @@ -1,90 +0,0 @@ -obtenir('smtp_host'), - (string) $configuration->obtenir('smtp_tls'), - $configuration->obtenir('smtp_username'), - $configuration->obtenir('smtp_password'), - (string) $configuration->obtenir('smtp_port'), - ); - } - - public function send(Message $message): void - { - $from = $message->getFrom(); - if (!$from instanceof MailUser) { - throw new UnexpectedValueException('Trying to send a mail with no sender'); - } - $phpMailer = $this->createPhpMailer(); - $phpMailer->setFrom($from->getEmail(), $from->getName()); - $phpMailer->isHTML($message->isHtml()); - $phpMailer->Subject = $message->getSubject(); - $phpMailer->Body = $message->getContent(); - foreach ($message->getRecipients() as $user) { - $phpMailer->addAddress($user->getEmail(), $user->getName()); - } - foreach ($message->getCc() as $user) { - $phpMailer->addAddress($user->getEmail(), $user->getName()); - } - foreach ($message->getBcc() as $user) { - $phpMailer->addAddress($user->getEmail(), $user->getName()); - } - foreach ($message->getAttachments() as $attachment) { - $phpMailer->addAttachment($attachment->getPath(), $attachment->getName(), $attachment->getEncoding(), $attachment->getType()); - } - - $phpMailer->send(); - } - - /** - * Génération et configuration de l'objet PHPMailer - */ - private function createPhpMailer(): PHPMailer - { - // Exceptions gérées - $mailer = new PHPMailer(true); - $mailer->CharSet = 'utf-8'; - if (null !== $this->smtpServer) { - $mailer->IsSMTP(); - $mailer->Host = $this->smtpServer; - $mailer->SMTPAuth = false; - } - if (null !== $this->tls && $this->tls !== '0') { - $mailer->SMTPAuth = true; - $mailer->SMTPSecure = 'tls'; - } - if ($this->username) { - $mailer->Username = $this->username; - } - if ($this->password) { - $mailer->Password = $this->password; - } - if ($this->port) { - $mailer->Port = (int) $this->port; - } - - return $mailer; - } -} From f54ad9188e8c67a6644401725c278345821ee9ff Mon Sep 17 00:00:00 2001 From: vgreb Date: Wed, 10 Jun 2026 18:39:05 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Suppression=20de=20la=20d=C3=A9pendance=20p?= =?UTF-8?q?hpmailer/phpmailer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 1 - composer.lock | 83 +------------------------------------------- phpstan-baseline.php | 48 ------------------------- 3 files changed, 1 insertion(+), 131 deletions(-) diff --git a/composer.json b/composer.json index 83ca4454f..3e7c06931 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,6 @@ "league/oauth2-github": "^3.1", "nyholm/psr7": "^1.8", "pear/pear": "^1.10", - "phpmailer/phpmailer": "^6.12", "phpoffice/phpspreadsheet": "^5.7.0", "pimple/pimple": "^3.6", "presta/sitemap-bundle": "^4.3", diff --git a/composer.lock b/composer.lock index aa336a75b..e4174d5c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "59e380a093941853e321ac2c73ba793f", + "content-hash": "2b829d682a03370932a35b2ea08cc74c", "packages": [ { "name": "algolia/algoliasearch-client-php", @@ -4296,87 +4296,6 @@ }, "time": "2024-10-02T11:20:13+00:00" }, - { - "name": "phpmailer/phpmailer", - "version": "v6.12.0", - "source": { - "type": "git", - "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "d1ac35d784bf9f5e61b424901d5a014967f15b12" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/d1ac35d784bf9f5e61b424901d5a014967f15b12", - "reference": "d1ac35d784bf9f5e61b424901d5a014967f15b12", - "shasum": "" - }, - "require": { - "ext-ctype": "*", - "ext-filter": "*", - "ext-hash": "*", - "php": ">=5.5.0" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "doctrine/annotations": "^1.2.6 || ^1.13.3", - "php-parallel-lint/php-console-highlighter": "^1.0.0", - "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcompatibility/php-compatibility": "^9.3.5", - "roave/security-advisories": "dev-latest", - "squizlabs/php_codesniffer": "^3.7.2", - "yoast/phpunit-polyfills": "^1.0.4" - }, - "suggest": { - "decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication", - "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", - "ext-openssl": "Needed for secure SMTP sending and DKIM signing", - "greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication", - "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", - "league/oauth2-google": "Needed for Google XOAUTH2 authentication", - "psr/log": "For optional PSR-3 debug logging", - "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", - "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPMailer\\PHPMailer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1-only" - ], - "authors": [ - { - "name": "Marcus Bointon", - "email": "phpmailer@synchromedia.co.uk" - }, - { - "name": "Jim Jagielski", - "email": "jimjag@gmail.com" - }, - { - "name": "Andy Prevost", - "email": "codeworxtech@users.sourceforge.net" - }, - { - "name": "Brent R. Matzelle" - } - ], - "description": "PHPMailer is a full-featured email creation and transfer class for PHP", - "support": { - "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.12.0" - }, - "funding": [ - { - "url": "https://github.com/Synchro", - "type": "github" - } - ], - "time": "2025-10-15T16:49:08+00:00" - }, { "name": "phpoffice/phpspreadsheet", "version": "5.7.0", diff --git a/phpstan-baseline.php b/phpstan-baseline.php index e4b6dfac0..27595761d 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1465,24 +1465,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/Afup/Utils/LegacyConnectionFactory.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getEmail\\(\\) on mixed\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Mailing.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$array of function reset expects array\\|object, array\\\\|null given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Mailing.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#2 \\$replace of function str_replace expects array\\\\|string, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/Afup/Utils/Mailing.php', -]; $ignoreErrors[] = [ 'message' => '#^Binary operation "\\." between mixed and \' \' results in an error\\.$#', 'identifier' => 'binaryOp.invalid', @@ -7471,36 +7453,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Adapter/MailerAdapter.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Argument of an invalid type array\\\\|null supplied for foreach, only iterables are supported\\.$#', - 'identifier' => 'foreach.nonIterable', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Cannot cast mixed to string\\.$#', - 'identifier' => 'cast.string', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#1 \\$smtpServer of class AppBundle\\\\Email\\\\Mailer\\\\Adapter\\\\PhpMailerAdapter constructor expects string\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#3 \\$username of class AppBundle\\\\Email\\\\Mailer\\\\Adapter\\\\PhpMailerAdapter constructor expects string\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Parameter \\#4 \\$password of class AppBundle\\\\Email\\\\Mailer\\\\Adapter\\\\PhpMailerAdapter constructor expects string\\|null, mixed given\\.$#', - 'identifier' => 'argument.type', - 'count' => 1, - 'path' => __DIR__ . '/sources/AppBundle/Email/Mailer/Adapter/PhpMailerAdapter.php', -]; $ignoreErrors[] = [ 'message' => '#^Argument of an invalid type array\\\\|null supplied for foreach, only iterables are supported\\.$#', 'identifier' => 'foreach.nonIterable', From 0b3a97ffe67ec79a63bd24b988294869e4170f4d Mon Sep 17 00:00:00 2001 From: vgreb Date: Wed, 10 Jun 2026 19:07:16 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Suppression=20des=20sauts=20de=20ligne=20en?= =?UTF-8?q?=20fin=20de=20sujet=20de=20mail=20n=C3=A9cessaires=20=C3=A0=20p?= =?UTF-8?q?hpmailer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/AppBundle/Accounting/InvoicingMailer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/AppBundle/Accounting/InvoicingMailer.php b/sources/AppBundle/Accounting/InvoicingMailer.php index 3bdb46dc9..7037fd2f1 100644 --- a/sources/AppBundle/Accounting/InvoicingMailer.php +++ b/sources/AppBundle/Accounting/InvoicingMailer.php @@ -25,7 +25,7 @@ public function sendInvoice(Invoicing $invoicing): bool { $invoiceNumber = $invoicing->getInvoiceNumber(); - $sujet = "Facture AFUP\n"; + $sujet = "Facture AFUP"; $corps = "Bonjour, \n\n"; $corps .= "Veuillez trouver ci-joint la facture correspondant à la participation au forum organisé par l'AFUP.\n";