sender_url should not contain mailto:

Created on 29 June 2024, 6 months ago
Updated 15 August 2024, 4 months ago

Hello, I'm using this module on a Drupal 10 site. And on the 'Mailer policy' page at Contact form ยป Message ยป *All*, I've modified the content slightly to more closely match the Default contact form's notification message:

<p>{{ sender_name }} ({{ sender_url }}) sent a message using the contact form at {{ form_url }}.</p>
<hr>
{{ body }}

This gets me pretty close, but there are 2 improvements I'd really like to make and can't figure out how.

#1. In the default contact form, the message shows the sender's e-mail address more clearly (and simply). For example, it looks like this:
Rob Roberts (not verified) (name@outlook.com) sent a message ...

However, with the above variables in place, the Symfony message looks like this:
Rob Roberts (not verified) (mailto:name@outlook.com) sent a message ...

I just want this to be clean and simple, and *not* show the "mailto" part since that is obvious and unnecessarily cluttered looking.

#2. At the end of the message, the default Drupal message text looks like this:
... using the contact form at https://www.domain.com/contact.

However, the Symfony version looks like this:
... using the contact form at /contact.

In this case, it would be preferable to show the entire URL since it's more informative and looks better as well

I have scoured Google, the "contact.module" file, and aside from the linked related issues I'm not finding anything of use. I appreciate that the work on these issues is complex, so in the meantime it'd be great if someone could enlighten me on how to do these 2 things:

  1. Change {{ sender_url }} to the desired variable
  2. Change {{ form_url }} to the desired variable

Since this is how the default Drupal text looks, I know it must be possible! Any help to make these small-yet-important (to me) changes would be much appreciated.

๐Ÿ› Bug report
Status

Needs work

Version

1.4

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States jimmb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jimmb
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jimmb
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    #1 is probably a bug. It comes from ContactEmailBuilderBase.php line 30 which adds in the mailto: . I don't really know why๐Ÿ˜ƒ.

    #2 should be corrected by "URL to absolute" in your All/All email policy. Maybe you removed it by mistake?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jimmb

    Thanks very much for the reply. And in light of this, then it looks like there may be 2 bugs ...

    For #1, it's good to at least know the likely cause of this. It's obviously not essential, but would be nice someday if this just showed the e-mail address like the default Drupal setup.

    For #2, I double checked and 'URL to absolute' is there. I've attached a screenshot from /admin/config/system/mailer, which shows that it's active. As such, I'm guessing that is a bug as well.

    Any ideas to troubleshoot this would be much appreciated. And naturally if you can fix either or both of these bugs, that would be fantastic!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    #1 if someone can make a merge request that does what I described in #3 then I will commit it

    #2 is working fine for me, so it needs steps to reproduce. If you could try on a clean site the problem might go away.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Prem Suthar โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Success
    5 months ago
    Total: 162s
    #241815
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Update the Changes Please Review.

  • Pipeline finished with Skipped
    5 months ago
    #243436
  • Status changed to Fixed 5 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Thanks

  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Wait a minute.

    The mailto: is there because the variable is supposed to be a URL, which you can put it inside a href. The default policy contains this line, and this patch has broken it.

    <a href="{{ sender_url }}">{{ sender_name }}</a> has sent you a message via your form at {{ site_name }}.

    Perhaps instead we could make a new variable sender_mail? However in that case it would change behaviour for a registered user, when the URL will be something like /user/{user}.

    Perhaps you can remove the mailto: in twig? See https://stackoverflow.com/questions/15600626/begins-with-in-twig-template.

    • AdamPS โ†’ committed 0bf397e4 on 1.x
      Revert "Issue #3457962 by Prem Suthar: sender_url should not contain...
Production build 0.71.5 2024