Drupal 8 site. I'm using the core Contact module for basic "Contact Us" form.

How can I get the email of the person submitting the form to be in the From field? And a follow-up: How do I get the email of an authenticated user to show in the body along with the username?

Site and users:

The site is an association website. There are about 100 user accounts.

Domain and email:

The site domain is not the same as the email domain in account settings: the site is theirsite.org and the email is theiremail@gmail.com

From & To in email

When the email came in from authenticated user or anonymous user, the From and the To are both showing theiremail@gmail.com - the site email.

What shows in body of email:

The email from the authenticated user does not show in the body of email; only the user name and the link to their user account /user/[user-number]

When I submit a form as an anonymous user the email does show in the body.

P.S. I do not want to use the Webform module.

  • Your observation is correct, in the body of the email an admin gets from the site when someone uses the contact form the email address of the visitor who sent the message is shown only when the visitor is anonymous, but if the visitor is authenticated then a link to their profile is shown instead. I'm guessing this is because the profile link provides a lot more information about the visitor (including their email), but you have to visit their profile to get the address. The code responsible for this is in contact.module, so you need custom code to to override it, or maybe use email templates.
    – prkos
    Aug 13, 2019 at 19:36

1 Answer 1


If the person submitting the form is an anonymous visitor the form will be empty and the visitor will have to fill in every field.

If the visitor is logged in (authenticated user) the name and email address are already pre-filled from their user profile.

Are you sure you're not testing this while being logged in as an admin account that has the same email address as the site? Then it's expected to see that email there.

Try to login as a different user, and also test as anonymous to see that the email is now from that different user/empty respectively for those two cases.

If you're constantly seeing the site email as From in all three cases then it's a bug and you should try to see where it's coming from. I haven't seen any problems with the Contact module, it's showing the correct "From" value every time.

  • Answer to your question: "Are you sure you're not testing this while being logged in as an admin account that has the same email address as the site?" The answer is No. FYI: I made some improvements to my question and some details to the original submission. Aug 13, 2019 at 17:27
  • This answer assumes you're asking about displaying the "From" information on the form on the site before it's being used, while it's now clear you're asking about the email message you get as an admin or user receiving a message from the site.
    – prkos
    Aug 13, 2019 at 19:30
  • The From issue was the most pressing. I wouldn't care if the email was in the body of the email if the From email was the email of the person submitting the form. Aug 13, 2019 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.