Modify from address for form submissions

Permalink
Hello:

I've searched through the forums but wasn't actually able to come up with a definite answer to whether what I want to do is possible or not.

We have a form that emails one of our staff with information that includes an email address.

When that staff member receives the submission, the from address is admin@mysite.com.

Is there any way to change the from address to the email that is submitted in the form?

Thanks!

 
LucasAnderson replied on at Permalink Reply
LucasAnderson
In /config/site.php add this:

define('FORM_BLOCK_SENDER_EMAIL ','whatever@what.com');

Obviously change the email to what you want.
brandor5 replied on at Permalink Reply
I saw this responded on other similar requests.

But I don't want the email to be set email address.

If joe@schmo.com submits the form, I want the email my staff member gets be from joe@schmo.com.
brandor5 replied on at Permalink Reply
Anyone else have a suggestion?

Am I just not understanding the suggestion above?

Is this possible at all?
Shotster replied on at Permalink Reply
Shotster
Yes, it's possible, but you'd have to delve into some PHP. There are a number of different approaches you could take, but it would likely involve overriding and customizing the form block - probably editing the action_submit_form() method in the controller.php file such that the "$formFormEmailAddress" variable uses the submitted address. (And yes, that's the name of the variable in the code, although "$formFromEmailAddress" is probably what was intended.)

-Steve
curiousconcepts replied on at Permalink Reply
I'm also trying to look for the solution as well, but no luck still.
seems like the alternative way is to get the Extended Form extension.
bw1 replied on at Permalink Reply
Reviving an old post, because I'm seeing conflicting and what looks like repetitive information and I'm not sure what is deprecated and what is current.

What is the proper way to specify the FROM ADDRESS and NAME that site emails (like form results, etc.) are sent using?

I've seen these throughout Concrete5.org, but had trouble with some/all of them, at some point or another:

define('EMAIL_DEFAULT_FROM_ADDRESS', 'website@example.com');
define('EMAIL_DEFAULT_FROM_NAME', 'Website Name');
define('FORM_BLOCK_SENDER_EMAIL, EMAIL_DEFAULT_FROM_ADDRESS');

I've gotten some to work, but I've also had some specified in the past that have broken and stopped working, at which point the site defaulted to sending from my USER email address (not even the SMTP-Out address), and I don't want mail coming from the user address.

So -- if someone could help with the proper method for 5.6+, that would be great.
mhawke replied on at Permalink Reply
mhawke
It depends. The hierarchy starts at line 435 of [root]/concrete/core/controllers/form.php It uses "FORM_BLOCK_SENDER_EMAIL" unless the form specifies a "sendEmailFrom". If neither of those exist, it uses the SuperUser's email address.

if ($this->sendEmailFrom !== false) {
    $formFormEmailAddress = $this->sendEmailFrom;
} else if( strlen(FORM_BLOCK_SENDER_EMAIL)>1 && strstr(FORM_BLOCK_SENDER_EMAIL,'@') ){
    $formFormEmailAddress = FORM_BLOCK_SENDER_EMAIL;  
}else{ 
    $adminUserInfo=UserInfo::getByID(USER_SUPER_ID);
    $formFormEmailAddress = $adminUserInfo->getUserEmail(); 
}
bw1 replied on at Permalink Reply
So where/how are EMAIL_DEFAULT_FROM_ADDRESS and EMAIL_DEFAULT_FROM_NAME used then?

Should I specify all three parameters in site.php?
mhawke replied on at Permalink Reply
mhawke
If you put what you posted above into your site.php, that should do it.