- Issue created by @vodde83
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Just ran into this issue trying to update to 10.1.x-dev. I'm wondering why you're having the trouble with 9.3+ already... but yes I can confirm there seems to be some kind of conflict:
Your requirements could not be resolved to an installable set of packages. Problem 1 - Root composer.json requires drupal/core-recommended 10.1.x-dev@dev -> satisfiable by drupal/core-recommended[10.1.x-dev]. - drupal/swiftmailer[2.4.0, ..., 2.x-dev] require egulias/email-validator ^2.0||^3 -> satisfiable by egulias/email-validator[2.0.0, ..., 2.1.x-dev, 3.0.0, ..., 3.x-dev]. - You can only install one version of a package, so only one of these can be installed: egulias/email-validator[1.2.0, ..., 1.2.x-dev, 2.0.0, ..., 2.1.x-dev, 3.0.0, ..., 3.x-dev, 4.0.0, 4.0.1, 4.x-dev]. - symfony/mime[v6.2.0-BETA1, ..., 6.3.x-dev] conflict with egulias/email-validator ~3.0.0. - drupal/core-recommended 10.1.x-dev requires egulias/email-validator ~4.0.1 -> satisfiable by egulias/email-validator[4.0.1]. - drupal/core-recommended 10.1.x-dev requires symfony/mime ~v6.3.0-RC1 -> satisfiable by symfony/mime[v6.3.0-RC1, 6.3.x-dev]. - Root composer.json requires drupal/swiftmailer ^2.4 -> satisfiable by drupal/swiftmailer[2.4.0, 2.x-dev].
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Setting priority to major as it seems this may become a larger issue when switching to Drupal 10.1.0?
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Let's try to also add the ||^4 compatibility line to the composer.json.
- ๐ฉ๐ชGermany webflo
I think it needs a complete fork of swiftmailer/swiftmailer to make it work.
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Thanks @webflo!
FYI: For us, this was the final nudge to make the switch to https://www.drupal.org/project/symfony_mailer โ
It worked quite well!
If it helps anyone: We didn't migrate any Swiftmailer settings.Simply uninstalled the swiftmailer & mailsystem module and installed symfony_mailer (without symfony_mailer_bc), left the default settings as-is and renamed the twig files and library. It simply worked! :)
Our only minor issue was the missingsubject
variable: โจ Pass mail subject to the twig files as variable FixedSo I won't invest anymore time into this issue. symfony_mailer is the future and while it was a pain some months ago, it seems to work well now :)
- ๐ง๐ชBelgium bramvandenbulcke
I also encountered this issue when updating to Drupal 10.1. Drupal drupal/core-recommended was updating to 10.1 beta. I just could't figure out the reason. I normally run composer update globally.
This was the information I needed to solve the problem (and ending up in this thread):
drupal/core-recommended 10.1.0 requires egulias/email-validator ~4.0.1
Uninstalling Swiftmailer and Mailsystem and replacing both with Symfony Mailer was indeed the solution. As said by Anybody: my custom email templates used with Swiftmailer are also working with Symfony Mailer.
- ๐ธ๐ฐSlovakia kaszarobert
So does this really mean that from Drupal 10.1 the swiftmailer module is no more? It would be good if someone from the maintainers could acknowledge that because this decision affects the required maintenance work on a lot of legacy sites when upgrading to the latest Drupal. Meaning composer update and drush updb won't be enough, the e-mail features will be needed to be redone completely.
Also, according to the Symfony Mailer docs about migrating from Swiftmailer โ it is mentioned that "Keep swiftmailer and mailsystem modules for now." That also won't be possible if these external dependencies will collide in the future.
- ๐ฉ๐ชGermany Anybody Porta Westfalica
@kaszarobert as of the technical reasons of this issue and the notes on the module page here, you can see that as confirmed, technically.
It's not a maintainers decision, we can't do anything about the base repo, see the issue summary.So YES. And you don't need to keep the Swiftmailer module. That should indeed please be updated in the docs. Can you do that?
Thanks!
- last update
over 1 year ago 19 pass - @claudiucristea opened merge request.
- last update
over 1 year ago 19 pass - last update
over 1 year ago Composer require failure - ๐ฎ๐ณIndia latha@dc
nagalatha_gampa โ made their first commit to this issueโs fork.
I had the same problem with upgrading to 10.1, and switched to symfony_mailer.
However, the switch did not go smoothly, and I want to write up what I found , just in case somebody else has the same Problem:Yes, after renaming the templates, emails did go out using those templates.
But at least in my case, there are special parameters that are being passed into the twig template (besides body), and these did not appear in the email. Basically, I had assumed that symfony_mailer was just a drop-in replacement for the normal way Drupal does email, using hook_mail etc, but that is not so.
Here is what I did:
1) I had to create a special class: /Plugins/EmailBuilder/MymoduleEmailBuilder.php
which gets assigned to the mail keys.
2) In there, fill in the various subroutines: createParams, fromArray, build. This is where I populate the parameters and pass them to the template. So for example, I have a $params array that I want to pass to the template, and here I set all the values; only then is this array available in the twig template, and I can use it like {{ params.some_value }}
3) After this is in place, hook_mail is basically ignored.You can see examples of this in the symfony_builder/src/Plugin/... tree itself.
I found the documentation for this very sparse, but these two links were helpful, epically the second one did 90% of what I needed, and I basically expanded from there:
- https://www.drupal.org/docs/contributed-modules/symfony-mailer-0/develop... โ
- https://arrea-systems.com/integration-with-symfony-mailer-drupal
Hope it helps.
- ๐ท๐ธSerbia holo96
If we are speaking about solutions, we've created a separate module which contains exactly the same formatter as swiftmailer (minimally modified).
And switched sender to SMTP Authentication Support โ
Considering we need to migrate hundreds of websites, I believe this is the best option at the moment. It's likely to work seamlessly, so no testing is needed.
Some of my websites also heavily rely on the mailsystem (and the core system). For me, the additional features in the Symfony mailer are just not worth it.
- ๐ช๐ธSpain guardiola86
This patch did not work for me, still says:
drupal/swiftmailer[dev-2.x, 2.4.0] require egulias/email-validator ^2.0||^3 - ๐บ๐ธUnited States DanChadwick
Composer patches are applied after composer analyzes the requirements. You'd need to create a local copy or fork containing the patch.
- Status changed to Needs review
about 1 year ago 8:54am 30 August 2023 - ๐ท๐ดRomania claudiu.cristea Arad ๐ท๐ด
Sorry for posting that MR, I was only experimenting. Ignore it. What you need is to replace
drupal/core-recommended
withdrupal/core
in your project composer.json. Remember thatdrupal/core-recommended
is just a wrapper arounddrupal/core
that locks Drupal dependencies to versions that are tested in Drupal CI. That doesn't mean newer dependency versions will not work but, true, you should carefully test them - First commit to issue fork.
- last update
about 1 year ago 19 pass - @ashm opened merge request.
- last update
about 1 year ago 19 pass - @ashm opened merge request.
- last update
about 1 year ago 19 pass - ๐ฉ๐ชGermany Anybody Porta Westfalica
@claudiu.cristea so there's no way to fix it in swiftmailer, right?
Should all MR's be closed?
- last update
about 1 year ago run-tests.sh fatal error - @anybody opened merge request.
- ๐ท๐ดRomania claudiu.cristea Arad ๐ท๐ด
@Anybody, you don't need to fix, see #11 ๐ฌ Conflicts with drupal/core-recommended 10.1.x-dev requires egulias/email-validator ~4.0.1 Active . I've closed the MR created by me, for the others I have no permissions
- ๐ญ๐บHungary mxr576 Hungary
What you need is to replace drupal/core-recommended with drupal/core in your project composer.json. Remember that drupal/core-recommended is just a wrapper around drupal/core that locks Drupal dependencies to versions that are tested in Drupal CI. That doesn't mean newer dependency versions will not work but, true, you should carefully test them
Based on past experiences, I rather focused on finding a solution that allows us to stick with drupal/core-recommended and also upgrade to Drupal 10 on projects that are still using Swift Mailer. Back then without drupal/core-recommended (and core-dev) it was way to easy for Composer to produce an unstable dependency composition. I would rather not try how it works nowadays.
So my solution is...
We are going to register the latest public stable release of Swift Mailer Drupal module (2.4.0) and the last public stable release of Swift Mailer PHP library (6.3.0) as the RC1 version of the next patch release.This is a three birds with one stone approach because:
- it unblocks the Drupal 10 upgrade
- It does not block future update of these packages to newer (stable) releases - if there will be any
- security scanners still report going to report that dependent projects are running on unsupported Swift Mailer module (and the abandoned library) - in contradiction to packages that would use the replace directive
Apply the following patch on a projectโs root composer.json. It contains only the minimum necessary package definitions from original composer.json files with a constraint change on egulias/email-validator. Since both components depended only public APIs of egulias/email-validator and they did not change between 3.x and 4.x, the following trick works.
diff --git a/composer.json b/composer.json --- a/composer.json (revision f72dcc34ceefd0a3145e58f325efd3c0610c71b9) +++ b/composer.json (revision 718dd37971a629170236905b56188bcca22cca20) @@ -99,6 +99,57 @@ }, "repositories": [ { + "type": "package", + "canonical": false, + "package": { + "name": "drupal/swiftmailer", + "type": "drupal-module", + "description": "Swift Mailer compatibility layer with drupal/core-recommended >= 10.1.0-rc1 that bumped the minimum required egulias/email-validator version to ~4.0.1.", + "version": "2.4.1-rc1", + "require": { + "drupal/mailsystem": "^4.1.0", + "egulias/email-validator": "^2.0|^3.0|^4.0", + "html2text/html2text": "^4.0.1", + "php": ">=7.0.0", + "swiftmailer/swiftmailer": "^6.3.1-rc1", + "tijsverkoyen/css-to-inline-styles": "^2.2" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/swiftmailer-8.x-2.4.zip" + }, + "_comment": "Read more at https://www.drupal.org/project/swiftmailer/issues/3359916", + "abandoned": "symfony/mailer" + } + }, + { + "type": "package", + "canonical": false, + "package": { + "name": "swiftmailer/swiftmailer", + "type": "library", + "description": "Swift Mailer compatibility layer with drupal/core-recommended >= 10.1.0-rc1 that bumped the minimum required egulias/email-validator version to ~4.0.1.", + "version": "v6.3.1-rc1", + "require": { + "egulias/email-validator": "^2.0|^3.1|^4.0", + "php": ">=7.0.0", + "symfony/polyfill-iconv": "^1.0", + "symfony/polyfill-intl-idn": "^1.10", + "symfony/polyfill-mbstring": "^1.0" + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "dist": { + "type": "zip", + "url": "https://github.com/swiftmailer/swiftmailer/archive/refs/tags/v6.3.0.zip" + }, + "_comment": "Read more at https://www.drupal.org/project/swiftmailer/issues/3359916" + } + }, + { "type": "path", "url": "web/modules/custom/*" },
After the patch is applied run
composer req drupal/swiftmailer:^2.4.1@rc -W
to install these forward compatible version of Swift Mailer packages. - ๐ธ๐ชSweden johnzzon Gothenburg ๐ธ๐ช
I ended up doing what @mxr576 suggested. This worked well. Gives me time to migrate to Drupal Symfony Mailer. Thanks for sharing your solution!
- ๐ฉ๐ชGermany jan kellermann
jan kellermann โ made their first commit to this issueโs fork.
- last update
about 1 year ago Fetch Error - @jan-kellermann opened merge request.
45:32 42:16 Running- last update
about 1 year ago Composer require failure - @jan-kellermann opened merge request.
- Status changed to RTBC
about 1 year ago 9:46pm 28 October 2023 - ๐ฉ๐ชGermany jan kellermann
Adding the
^4
constraint solves the problem. - Status changed to Active
about 1 year ago 9:55pm 28 October 2023 - ๐จ๐ญSwitzerland berdir Switzerland
No, it doesn't. swiftmailer/swiftmailer has that requirement, that will not be updated and is dead. There is and will be no "fix" for this.
One workaround is some composer trickery to override the constraints per #32.
However, consider using https://www.drupal.org/project/symfony_mailer_lite โ instead if the switch to symfony_mailer is understandably too much of a jump. That's very close in functionality and behaviour to swiftmailer module, just with symfony/mailer.
- ๐จ๐ฆCanada joseph.olstad
#32 is overkill
All I did was this:
I added this to my composer require section:
"egulias/email-validator": "4.0.3 as 3.0.3"
Then I ran the composer up command with all the components listed as parameters , or if you're brave, with -W
Just to add to "symfony mailer lite" (Berdirs comment above): I am running this on multiple production sites without a flaw. It is a true one-to-one drop in replacement for swiftmailer, no code changes required (uses hook_mail just as before); you just set it in "mailsystem" configs and your done.
- ๐จ๐ฆCanada joseph.olstad
@hoporr, is it that easy?
what about configuration settings that refer to swiftmailer?mailsystem.settings.yml
defaults: sender: phpmailer_smtp formatter: swiftmailer
you didn't even have to change this?
@joseph.olstad: You go into the mailsystem interface and where it used to say swiftmailer, you set it to symfony_mailer_lite. Done. (Alternatively, you edit that config there).
- ๐บ๐ฆUkraine nginex
#43 works perfect for me, I used the following
"egulias/email-validator": "4.0.2 as 3.2.6"
Here is a result
- Upgrading drupal/core-recommended (9.4.15 => 10.1.6)
- last update
11 months ago run-tests.sh fatal error - last update
11 months ago 19 pass - last update
11 months ago Composer require failure - ๐ซ๐ทFrance Striknin Lyon
#47 ๐ฌ Conflicts with drupal/core-recommended 10.1.x-dev requires egulias/email-validator ~4.0.1 Active Works perfectly !
Simply add this require in composer.json :"egulias/email-validator": "4.0.2 as 3.2.6"
and run :
composer update egulias/email-validator -W composer require 'drupal/swiftmailer:^2.4' --update-with-dependencies
#43 ๐ฌ Conflicts with drupal/core-recommended 10.1.x-dev requires egulias/email-validator ~4.0.1 Active not working on D10.1.7 (conflicts with symfony/mime v6.3.5)
- First commit to issue fork.
- last update
11 months ago Composer require failure - First commit to issue fork.
- last update
11 months ago Composer require failure - ๐จ๐ฆCanada joseph.olstad
MR 20 looks good, thanks @greenskin,
this needs to be committed into the code base. - Status changed to RTBC
11 months ago 8:53pm 2 January 2024 - ๐จ๐ฆCanada joseph.olstad
ignore the failure, it's a chicken and egg thing.
- Status changed to Active
11 months ago 11:00pm 3 January 2024 - ๐จ๐ญSwitzerland berdir Switzerland
As explained in #41, no, no change in this module can fix this and this doesn't need to be committed. The swiftmailer require change does nothing, composer will default to the most recent version and swiftmailer/swiftmailer itself (also) conflicts on the version.
Several workarounds have been posted, including aliases, not using drupal/core-recommended, custom repositories, but it doesn't change the fact that swiftmailer/swiftmailer is an abandoned project and replaced with symfony/mailer. The only sensible long-term solution for your projects is to switch to a project like symfony_mailer_lite or symfony_mailer. symfony/mailer is now even a drupal/core dependency since 10.2, but the included experimental mailer plugin doesn't yet support any of the extra features of either of those two drupal modules like support for HTML mails nor a UI to configure it, that will come later.
- ๐จ๐ฆCanada earthangelconsulting
we are still in the final testing stages, but it seems that #41 (using symfony_mailer_lite โ ) worked really well for us. all existing mail templates, etc. set up for swiftmailer are working fine. the emails marked as HTML (eg: in webforms) are still being delivered as HTML with no obvious changes.
that being said, we actually have Mailchimp Transactional mailer set as the formatter and the sender, in the mailsystem page /admin/config/system/mailsystem ... however i am still quite sure that symfony_mailer_lite is doing the trick because:
- in our DDEV development sites, which are not using mailchimp, emails are still being sent correctly
- if i understand this, then regardless of what you have set as your mailsystem, swiftmailer is what was providing
hook_mail()
andhook_mail_alter()
, correct? and symfony_mailer does not provide those, though symfony_mailer_lite does? if that is correct, then it is definitely working, as some things that are being set inhook_mail()
calls by various contrib modules are still working properly.i definitely suggest trying this approach. just install symfony_mailer_lite and it will take over (once the mailsystem page is pointing to it, see below) and then uninstall swiftmailer once you are sure it's working. if you are already in an upgrade situation where swiftmailer is already gone, that's fine, just make sure you check your backup sites, etc. and get any config needed for setting up symfony_mailer_lite (eg: SMTP ports... see below) unless you are just using "php native sendmail" (which has no config details, not within Drupal anyhow).
aside from installing it, you will need to:
- set symfony_mailer_lite as your Formatter and Sender, on the mailsystem page /admin/config/system/mailsystem (kind of obvious but i am writing this to help intermediate level devs, as well as experts ;-)
- configure symfony_mailer_lite at /admin/config/system/symfony-mailer-lite/transport and /admin/config/symfony-mailer-lite/message-settings and test it at /admin/config/system/symfony-mailer-lite/test if using "native php sendmail" to send, it should already be configured on install. if you are using Sendmail or SMTP or other methods, you will need to plug in the hostnames, port numbers, etc. (unless you find that symfony_mailer_lite has copied them correctly from your swiftmailer setup, which it might!) any other issues... refer to https://www.drupal.org/project/symfony_mailer_lite โ
i apologize for any uncertainty about some of the details in the above, this was done very quickly and when most of the way through a very complicated upgrade... though i can safely say that in this case, symfony_mailer_lite saved our butts. thanks maintainers for that sweet module!
- ๐จ๐ฆCanada joseph.olstad
symfony_mailer_lite worked out for us, although I did have to push up a patch to it for some reason , the developer quickly responded and improved it and we no longer need the patch.
- ๐จ๐ฆCanada earthangelconsulting
@joseph.olstad what was the patch, and what version were you using before patching? i need to see if this applies to my situation.
- ๐จ๐ฆCanada joseph.olstad
It's resolved since, just grab the latest release of symfony_mailer_lite , but since you asked, here it is:
๐ Lite: Allow sending back-compatibility email with empty To Fixed - ๐น๐ทTurkey emircan erkul Turkey
I just need that temporarily to be removed from our system flawlessly. But requiring that forces egulias/email-validator package to use 3.0.x instead of 4.0.x by
composer why egulias/email-validator swiftmailer/swiftmailer v6.3.0 requires egulias/email-validator (^2.0|^3.1)
I'm using https://git.drupalcode.org/issue/swiftmailer-3359916/-/commits/3359916-d...
I think there is no easy way to enforce egulias/email-validator 4.0