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.

CommentFileSizeAuthor
#4 Screenshot-143013.png18.78 KBjimmb
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jimmb created an issue. See original summary.

jimmb’s picture

Issue summary: View changes
adamps’s picture

#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?

jimmb’s picture

StatusFileSize
new18.78 KB

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!

adamps’s picture

Title: Changing Message Variables to Match Drupal Defaults » sender_url should not contain mailto:
Component: Documentation » Code
Category: Support request » Bug report

#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.

Prem Suthar made their first commit to this issue’s fork.

prem suthar’s picture

Status: Active » Needs review

Update the Changes Please Review.

  • AdamPS committed 22de64a4 on 1.x authored by Prem Suthar
    Issue #3457962 by Prem Suthar: sender_url should not contain mailto:
    
adamps’s picture

Status: Needs review » Fixed

Thanks

adamps’s picture

Status: Fixed » Needs work

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...
adamps’s picture

Status: Needs work » Postponed (maintainer needs more info)

#1 is working as designed - the field is called sender URL, and so it should be a URL. I understand that some people would like the sender mail. See #11 for how this could be done in TWIG.

#2 needs steps to reproduce