This module alters the entity edit forms (for contact and simplenews) to hide some elements and instead embed a widget to edit mailer policy. The same change should be made for the entity add forms.

Original report

PHP 8.0.18
Drupal 9.3.13

Step to reproduce: Open Contact page and send a message to site with copy to user.

  1. Mail System + Swift Mailer Modules: it Works !
  2. Symfony Mailer + BackCompatibility (Alpha 9): Error sending email: An email must have a "To", "Cc", or "Bcc" header.
    Email To site : no email
    Copy To user: it Works!.

Comments

gilbertdelyon created an issue. See original summary.

adamps’s picture

Title: Contact mail critical issue » Contact mail copy to user not working
Priority: Critical » Normal
Issue tags: -Contact mail critical issue
gilbertdelyon’s picture

Finally I could make it work !
D9.3.1
Symfony dev version
Test1: Mailer Policies: native settings

  1. Send a message with native contact form,
    without copy to user:
    Doesn't work at all
    Warning message: An email must have a "To", "Cc", or "Bcc" header.
  2. Send a message with native contact form,
    with copy to user:
    Message to site Doesn't work
    Message to user works
    Warning message: An email must have a "To", "Cc", or "Bcc" header.

Test2: Mailer Policies: I add à "To" field in "contact Form message " policy.
It works! No more warning.

If you go to admin>site structure>contact forms you can see a native "to" email adress in regard with current contact form.
If you open the setting page of this form you can read the following in "MAILER POLICY" area:
Configure Mailer policy records to customise the emails sent for Contact form. You can set the Subject, Body, To and more. .
Its confusing. Instead we should read "you MUST set To"

Please tell me if I missed something.

adamps’s picture

Title: Contact mail copy to user not working » Allow/require configuring 'To' address when adding contact form
Issue tags: +Needs issue summary update

Thanks I see. Please can you update the issue summary?

This module changes the edit contact form to remove the recipient field and add a mailer policy section. We need the same for the add contact form. The fix belongs in symfony_mailer_bc_form_alter().

Probably we have the same bug for Simplenews newsletter.

Its confusing. Instead we should read "you MUST set To"

True - however this text is automatically generated from the annotation in ContactPageEmailBuilder, see common_adjusters. I guess the solution is to create a required_adjusters field which would generate the text you suggest and raise an error if the adjuster is missing.

gilbertdelyon’s picture

Issue summary: View changes
gilbertdelyon’s picture

Issue summary: View changes
gilbertdelyon’s picture

1/ Summary updated.

2/ Simplenews newsletter ? Not tested, I am not using it.

3/

True - however..... blablabla.....is missing

I am not clever enough in Drupal code to say if this is the right way. My idea would be to simply pick up the "To" adress from the native Drupal form setting. (may be too simplistic !)

adamps’s picture

Title: Allow/require configuring 'To' address when adding contact form » Allow configuring mailer policy when adding contact form or newsletter
Version: 1.0.0-alpha9 » 1.x-dev
Component: Miscellaneous » Code
Issue summary: View changes
Status: Active » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new1.49 KB

Here is a patch that alters the 'add' form.

adamps’s picture

I created a new issue #3303340: Add support for required config as a follow-on task

adamps’s picture

Status: Needs review » Fixed

  • AdamPS committed d0ae19b on 1.x
    Issue #3281120 by AdamPS: Allow configuring mailer policy when adding...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.