How to add form sender's name to email subject heading?

Permalink 2 users found helpful

I'd like to have the form block include the sender's name (or email address, or date/time stamp) in the subject line of the email that's sent.

So, I have a form with these fields: message, name, email address

I have the form set to send me an email when someone submits this form. I want that email to include the sender's name or email address in the subject line of the email I receive.

I have gmail set to enable conversation view, so when multiple emails come in with the same subject line, it combines them all together. I need to make each email's subject line different somehow.

I'm using Concrete and I've already used this solution for changing the from address: in case there's some way I can just add to that file.


View Replies:
webpresso replied on at Permalink Reply
I'm interested in this too!
girlinabillion replied on at Permalink Reply
Well, created fields, including the name field you created has its own ID, so if you've got more than one form, it would cause a problem because it would be looking for the ID for that particular field. If you want this, the member BlueFractals was willing to code it for a reasonable fee.

If you're ok with putting the reply-to address there instead of a name, then you can just do one of the following.

You can change the code of the original file (though if you ever update Concrete it will erase your changes):

1) Open up /concrete/blocks/form/controller.php
2) Search for this line: $mh->setSubject(t('%s Form Submission', $this->surveyName));
It should be around line 570.
3) Replace the above line with
$mh->setSubject(t('[Email: %s] %s Form Submission', $replyToEmailAddress, $this->surveyName));

4) On your form block, you may also need to edit the email field and tick the box that says something like "Reply to this email".

Instructions courtesy of member BlueFractals.

Or instead of messing with any of the core files, you can just override them by creating a controller.php file and putting it under the /application/blocks/form/ directory. You may need to create some of this directory.

With that file, I set the subject line to say "Enquiry [email protected]" If you want it to read the form name, etc, you can copy the line from above and replace it in the attached file.

Here's the code that I used, courtesy of member jasteele12.

<?php /* application/blocks/forms/controller.php - overrides the concrete/blocks/forms/controller.php */
namespace Application\Block\Form;
use Core;
use Database;
use Config;
use User;
use UserInfo;
use Page;
class Controller extends \Concrete\Block\Form\Controller {
     * Override to add the form submitter's email address to the Subject (prevent Gmail folding).
    *       Search for $mh->setSubject below.
    * @author      John Steele
     * @copyright   2015 Steelesoft Consulting. All rights reserved worldwide.
pixeljunkie replied on at Permalink Reply
Wow, this worked just fine for me too. Thanks for the thread. Just one more question: Is there a way to adjust the email's »name« settings? What I'm getting at is that in the inbox it shows my admin email address in the »name« column. Is there a way to change that to - for example - »Booking request«?

Thanks for you help!
girlinabillion replied on at Permalink Reply
I don't know, but here's a start for what things to search for: