Sending Email to Different Address Based on Certain Criteria

the mail() function

Moderators: macek, egami, gesf

FriarTuck00
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Dec 06, 2012 7:59 am

Sending Email to Different Address Based on Certain Criteria

Postby FriarTuck00 » Thu Dec 06, 2012 8:12 am

I'm a PHP newbie, so please bear with me.

We have some PHP script on our site for when visitors fill out the different forms on the site. On our Contact Us form, site viewers can select which of our two locations they are interested in.

What I'm looking for is how I can code it so that if a viewer selects Location "A", the email goes to email address "a" and if the viewer selects Location "B", the email goes to email address "b".

Thanks!

User avatar
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: Sending Email to Different Address Based on Certain Crit

Postby egami » Fri Dec 14, 2012 8:46 am

if ($_POST['whatever'] == 'A') {
$email = "thisemail@address.com";
} elseif ($_POST['whatever'] == 'B') {
$email = "theotheremail@address.com";
} else {
$email = "defaultemail@address.com";
}


done.

harekumar
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Dec 18, 2012 10:13 pm

Re: Sending Email to Different Address Based on Certain Crit

Postby harekumar » Tue Dec 18, 2012 10:18 pm

The best way to send emails to any address just use the if else condition to identify the user response. And once you get the user response then use mail() function to do your stuff.


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest