Developer Support »

Using one copy of the script to send to different email addresses depending on a form input  (See more user questions)

You're making perfect sense, !

Thank you for your kind words.

Making four copies of the script is certainly the most straight-forward solution. There isn't a configuration in the script to change the email dependent on an inputted field, but have a look at this previously asked question:

https://formtoemail.com/user-questions/question_266.php

It means putting the email address in a hidden field on the form which isn't really advisable.

Have a look also at the article on my support section for selecting a recipient from a list:

https://formtoemail.com/developersupport/select_form_recipient.php

...it's not exactly what you are after but could give you some pointers.

Just off the top of my head:

You could put a hidden input on each form to identify it e.g:

<input type="hidden" name="form_name" value="sales">

<input type="hidden" name="form_name" value="support">

Then put this code in the script:

if(isset($_POST['form_name']))
{

if($_POST['form_name'] == "sales"){$my_email = "sales@example.com";}
if($_POST['form_name'] == "support"){$my_email = "support@example.com";}

}

Put it after this line in the script:

$my_email = "delete these words and put the email address(es) only, in here between the quotes";

That should do you!

Best wishes.

Charles Sweeney
https://formtoemail.com
The world's easiest feedback script!

On 23/06/2011 10:49, wrote:
> Thank you so much for the prompt reply Charles, it's so good to see that you
> are still upholding the high-standards of customer support that you're known
> for!
>
> I'm sure that J will examine your site and FAQ's carefully before
> contacting you with any questions. Typically I handle all support directly
> myself so as not to burden you, but I'm in a bit of a jam / time-crunch at
> the moment and I couldn't immediately see what is wrong with J's code.
> I hope you don't mind terribly that I've passed just this one customer along
> to you for a little guideance.
>
> In fact, I'm currently swapping out some old CGI formmail scripts on several
> customer sites with your script, and I've got a small question of my own.
> I've checked through your site and FAQ's and either I'm overlooking the
> answer or it is not there - I'm wondering if it is possible to have multiple
> contact forms in a single site / single directory, using this script, and
> have them each go to a different recipient.
>
> For example, let's say I own "example.com" and I have the formtoemailpro.php
> file uploaded to the public_html folder of example.com. Now let's say I have
> 4 contact forms - one for sales, one for support, one for general questions,
> and one for manager. With each html form I'd like to have the form
> submissions go directly to a respective recipient (sales@example.com ,
> support@example.com , general@example.com , manager@example.com ). However,
> I can't seem to figure out how to make the formtoemailpro.php file and the
> individual html form pages send to only one of the specific addresses based
> on which form they are submitting.
>
> Am I just completely overlooking something that's right in front of me? Or
> would such a thing require that I upload the formtoemailpro.php file by 4
> different names, and then have each of the 4 html forms call post to one of
> the specifically named formtoemailpro.php files?
>
> I hope that my question made sense, but if not just say "D, you're not
> making sense" and I'll try to better word my question.
>
> Thank you very very much!
> D