Cast Iron Coding, Inc

TYPO3 Admin's Corner

Click here to return to the TYPO3 Admin's Corner

Stay Connected

Complete the form below to sign up for the CIC newsletter. We send out about one message each month and we do our best to make sure it's full of useful information about TYPO3. We'll never share your email address with a third-party and should you ever change your mind, unsubscribing is a breeze.
Configuring TYPO3

Getting the Sender’s Name and E-mail Address in TYPO3’s Formmail Element

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.

By: Lucas Thurston

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

Posted on Wednesday, August 23, 2006 at 03:11 PM.