
The formmail content element is an easy way to pop a contact form on the page, but details on configuring it are sparse and incomplete. In this short article Lucas demonstates one cool thing we can do to get the most out of formmail: getting the author's name and e-mail to appear in the contact email.
Setting up contact forms or mail forms in TYPO3 is pretty easy thanks to a straight-forward configuration syntax and the Form Wizard. One nice feature that isn’t easy to find information about is getting the contact e-mail to be populated with the sender’s e-mail address and name, removing the unnecessary burden of copying and pasting the e-mail address from the message text. Also, when we see the e-mail in our mail client, we have a person’s name rather than “Nobody” or the server name in the name field.
The way we achieve this is by using a reserved variable name from the t3lib_formmail class. The reserved names list is on line 70 of the link to the TYPO3 API (fourth link in the list below). The values we are interested in are: “from_name” and “from_email” (although “email” seems to work too).
Here’s what our mail form configuration looks like (the asterisks make the marked values required for submission):
Name | *from_name=input,35
E-mail | *from_email=input,35
And that’s it! The next mail form e-mail you receive will have those values populated. Take a look at the other reserved names in the t3lib_formmail class for anything else that may be of use to you.
Want to make sure the submitted e-mail address is valid before submission? Change the e-mail line of the configuration to:
E-mail | *from_email=input,35 | | EMAIL
Have fun!
Relevant links:
www.mcuniverse.com/05/Mailforms.76.0.html
www.mcuniverse.com/05/Mailforms_II.79.0.html
http://typo3.org/documentation/document-library/tutorials/doc_tut_quickstart...
http://typo3.org/fileadmin/typo3api-4.0.0/...