Account created on 19 June 2016, about 8 years ago
#

Recent comments

Other problems have arisen . I gave up and switched to Drupal Symfony Mailer Lite.
Feel free to ignore this.

Contact forms contain by default two fields named "sender name" and "sender email".
The problem is caused by the fact that i disabled those fields in my form (instead of the "sender name" field, i added two separated fields for "name" and "last name").
As a result, the contact form module is passing an empty sender of type AccountInterface.
This used to work with the old swift_mailer module, that used the website default email address as a fallback.

Right now i patched the problem by forcing symfony mailer to use the website default email address as the sender:

--- Address.php.bak     2024-04-03 08:42:11.564698369 +0000
+++ Address.php 2024-04-03 08:42:38.244623682 +0000
@@ -83,7 +83,9 @@
       }
     }
     elseif ($address instanceof AccountInterface) {
-      return new static($address->getEmail(), $address->getDisplayName(), $address->getPreferredLangcode(), $address);
+      $site_config = \Drupal::config('system.site');
+      $site_mail = $site_config->get('mail') ?: ini_get('sendmail_from');
+      return new static($site_mail, $site_config->get('name'));
     }
     elseif ($address instanceof SymfonyAddress) {
       return new static($address->getAddress(), $address->getName());

Of course this is a bad hack, and i would like to implement a better solution.
I think that at least symfony_mailer should detect when $address->getEmail() is null and avoid the php error.

Production build 0.69.0 2024