Add ability in contact form to reply to the submitter

Permalink 2 users found helpful
I thought it would be nice to make an email form on a C5 site and allow people to include a "reply to" or "from" address. Currently, C5 only has the option to include the owner of the page in the "from" portion of the emailed form. This gets really annoying if you use the form for questions and feedback because you have to copy+paste the email address into a new email and reply that way.

I wrote a simple fix on the PHP page SITE/concrete/blocks/form/controller.php

Just make the change below (simply search for one of the lines to find the right place, somewhere in the lines 300 to 350 territory, and you can figure out the rest):

   //  New line below.

and this change:

$mh->to( $this->recipientEmail );
//  $mh->from( $formFormEmailAddress );  is the old line
$mh->from( $fromEmail );  //  is the new line

This makes the "email" field of a form into the "from" or "reply to" field when it arrives in your inbox. It would be nice if this were added to C5 permanently, but it's a really easy fix even if they don't.

View Replies:
107studio replied on at Permalink Reply
Tried this on version 5.5.1 and it didn't work.
How do you create an input type of email in the contact form. The selection only includes:

Text Field
Text Area
Radio Buttons
Select Box
Checkbox List
File Upload

my results were that my email from line was [email protected]
curtis07 replied on at Permalink Reply
I am not sure what you're asking. If you have changed something, but the behavior of the form is not changing, try clearing the cache in the dashboard.
Riteshdas replied on at Permalink Reply
Hi Curtis,

thank you for posting this, I am trying to figure out how to get to the correct place to make that change. I've tried through 'edit block and design', could you direct me to the right location?

Thank you!
curtis07 replied on at Permalink Reply
You have to get the file using FTP and then edit it using a text editor. I explained where you find it in the post.
SamS replied on at Permalink Reply
I've also tried this code, and for it worked until I started updating my sites to the most recent version. Something has changed, but not sure what. Anybody else experience this?
furehead replied on at Permalink Reply
Thank you curtis for these lines. Worked great for me (I modified it a bit to change only the replyto-Adress).

@SamS: You should not change any code in the /concrete/ directory and below.
Always copy files you want to change into the correct path below your root outside /concrete/ because otherwise your patch will not work after updates.

If anybody needs a more detailed process I tried my explanation here:
TorstenKelsch replied on at Permalink Reply
The whole structure has changed in concrete5 5.6.x. The code can no longer be found in /concrete/blocks/form/controller.php. Instead, now you can check a checkbox in the form designer when you add an email field. But the problem is: the checking is not saved. I tried on two different web hosting environments, but it does not work. Does anybody have a fix for this?
leertes replied on at Permalink Reply

I couldn't get the Reply to to do anything here is a rather horrible hack that sends a second email at the same time

around line 445

$mh = Loader::helper('mail');
$mh->to( $this->recipientEmail );
$mh->from( $formFormEmailAddress );
$mh->replyto( $replyToEmailAddress );
$mh->addParameter('formName', $this->surveyName);
$mh->addParameter('questionSetId', $this->questionSetId);
$mh->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh->body.'<br>';

This sends the first email -

Directly underneath add this

$mh2 = Loader::helper('mail');
$mh2->to( $replyToEmailAddress );
$mh2->from( $formFormEmailAddress );
$mh2->addParameter('formName', $this->surveyName);
$mh2->addParameter('questionSetId', $this->questionSetId);
$mh2->addParameter('questionAnswerPairs', $questionAnswerPairs);
$mh2->setSubject(t('%s Form Submission', $this->surveyName));
//echo $mh2->body.'<br>';

This will fire an email back to the replytoemailaddress that was collected as the email in the form.

I hope this works for you!
aphotographycompany replied on at Permalink Reply
Thank you for this. It worked perfectly for me today.

I changed the lines in this file: