Link to home
Start Free TrialLog in
Avatar of spoggles
spoggles

asked on

php mail() function

Hello experts!

I have a question regarding the php mail() function. I have attached my php code that will process the Order and send it out. It works just fine, but what happens if you put another mail() function in this code?

In this example, we have two different companies that handle our yard signs and decal signs. If the customer wants yards signs it goes to yardsigns@orders.com and if the customer wants decals then it goes to decals@orders.com. Is this possible with another mail() function and an if statement?

I want to be able to keep the orders separate - I don't want yardsigns@orders.com receiving orders for decals and vice versa.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spoggles
spoggles

ASKER

@Ray_Paseur, I am going to take your advice and pick up the php book.

For the instant question, here is my sendOrder.php. What I want is to have the Decals orders go to decals@orders.com while the rest of the order goes to signs@orders.com. Ideally, I would not want the Decals to go to signs@orders.com and vice versa.

The problem I'm having is that I do not know how to branch off into another e-mail function while keeping it effective. The live webpage is located at: http://tuckertoolbox.com/signs 
<?php
// Pick up the form data and assign it to variables

//Order Information
$OfficeName = $_POST['OfficeName'];
$date = date("D F d Y");
$time = date("h : i a");
$deliveryDate = $_POST['deliveryDate'];
$name = $_POST['orderedBy'];
$email = $_POST['email'];
$phoneNumber = $_POST['phoneNumber'];
$address = $_POST['address'];
$cityStateZip = $_POST['cityStateZip'];

//F.C. Tucker Metro Signs
$Open_House_Yard_Signs = $_POST['Open_House_Yard_Signs'];
$Sold_Rider = $_POST['Sold_Rider'];
	//Start Open House Sign Riders
	$tweleveTOtwo = $_POST['tweleveTOtwo'];
	$tweleveTOtwoANDthreeTOfive = $_POST['tweleveTOtwoANDthreeTOfive'];
	$tweleveTOthree = $_POST['tweleveTOthree'];
	$tweleveTOfour = $_POST['tweleveTOfour'];
	$tweleveTOfive = $_POST['tweleveTOfive'];
	$oneTOthree = $_POST['oneTOthree'];
	$oneTOfour = $_POST['oneTOfour'];
	$oneTOfive = $_POST['oneTOfive'];
	$twoTOfour = $_POST['twoTOfour'];
	$twoTOfive = $_POST['twoTOfive'];
	$threeTOfive = $_POST['threeTOfive'];
	//End Open House Sign Riders
$U_Bracket = $_POST['U_Bracket'];
$Adapter = $_POST['Adapter'];
$Metro_Yard_Sign = $_POST['Metro_Yard_Sign'];
$Condo_For_Sale = $_POST['Condo_For_Sale'];
	//Photo Rider or Custom Verbiage  Rider
	$Photo_Rider_A = $_POST['Photo_Rider_A'];
	$Copy_Line1_A = $_POST['Copy_Line1_A'];
	$Copy_Line2_A = $_POST['Copy_Line2_A'];	
	$Bill_to_A = $_POST['Bill_to_A'];
	
	$Photo_Rider_B = $_POST['Photo_Rider_B'];
	$Copy_Line1_B = $_POST['Copy_Line1_B'];
	$Copy_Line2_B = $_POST['Copy_Line2_B'];	
	$Bill_to_B = $_POST['Bill_to_B'];
	
	$Photo_Rider_C = $_POST['Photo_Rider_C'];
	$Copy_Line1_C = $_POST['Copy_Line1_C'];
	$Copy_Line2_C = $_POST['Copy_Line2_C'];	
	$Bill_to_C = $_POST['Bill_to_C'];
	
	$Photo_Rider_D = $_POST['Photo_Rider_D'];
	$Copy_Line1_D = $_POST['Copy_Line1_D'];
	$Copy_Line2_D = $_POST['Copy_Line2_D'];
	$Bill_to_D = $_POST['Bill_to_D'];

	//Start Decal Orders
	$DecalType = $_POST['DecalType'];
	$Quantity_Regular_A = $_POST['Quantity_Regular_A'];
		$Name_Regular_A = $_POST['Name_Regular_A'];
		$Contact_Regular_A = $_POST['Contact_Regular_A'];	
	$Quantity_Regular_B = $_POST['Quantity_Regular_B'];
		$Name_Regular_B = $_POST['Name_Regular_B'];
		$Contact_Regular_B = $_POST['Contact_Regular_B'];	
	$Quantity_Regular_C = $_POST['Quantity_Regular_C'];
		$Name_Regular_C = $_POST['Name_Regular_C'];
		$Contact_Regular_C = $_POST['Contact_Regular_C'];		
	
$comments = $_POST['comments'];	
//End F.C. Tucker Metro
	
//F.C. Tucker Affiliate Signs
$Aff_Open_House_Yard_Signs = $_POST['Aff_Open_House_Yard_Signs'];
$Aff_Sold_Rider = $_POST['Aff_Sold_Rider'];
	//Start Open House Sign Riders
	$Aff_tweleveTOtwo = $_POST['Aff_tweleveTOtwo'];
	$Aff_tweleveTOtwoANDthreeTOfive = $_POST['Aff_tweleveTOtwoANDthreeTOfive'];
	$Aff_tweleveTOthree = $_POST['Aff_tweleveTOthree'];
	$Aff_tweleveTOfour = $_POST['Aff_tweleveTOfour'];
	$Aff_tweleveTOfive = $_POST['Aff_tweleveTOfive'];
	$Aff_oneTOthree = $_POST['Aff_oneTOthree'];
	$Aff_oneTOfour = $_POST['Aff_oneTOfour'];
	$Aff_oneTOfive = $_POST['Aff_oneTOfive'];
	$Aff_twoTOfour = $_POST['Aff_twoTOfour'];
	$Aff_twoTOfive = $_POST['Aff_twoTOfive'];
	$Aff_threeTOfive = $_POST['Aff_threeTOfive'];
	//End Open House Sign Riders
$Aff_U_Bracket = $_POST['Aff_U_Bracket'];
$Aff_Adapter = $_POST['Aff_Adapter'];
$Aff_Yard_Sign = $_POST['Aff_Yard_Sign'];
	$Aff_Yard_Sign_Name = $_POST['Aff_Yard_Sign_Name'];
	$Aff_Yard_Sign_Number = $_POST['Aff_Yard_Sign_Number'];
$Aff_Stock_Verbiage_Rider = $_POST['Aff_Stock_Verbiage_Rider'];	
$Aff_Condo_For_Sale = $_POST['Aff_Condo_For_Sale'];
$Aff_Directional_Sign = $_POST['Aff_Directional_Sign'];
$Aff_Open_House_Directional_Sign = $_POST['Aff_Open_House_Directional_Sign'];
	//Photo Rider or Custom Verbiage  Rider
	$Aff_Photo_Rider_A = $_POST['Aff_Photo_Rider_A'];
	$Aff_Copy_Line1_A = $_POST['Aff_Copy_Line1_A'];
	$Aff_Copy_Line2_A = $_POST['Aff_Copy_Line2_A'];	
	$Aff_Bill_to_A = $_POST['Aff_Bill_to_A'];
	
	$Aff_Photo_Rider_B = $_POST['Aff_Photo_Rider_B'];
	$Aff_Copy_Line1_B = $_POST['Aff_Copy_Line1_B'];
	$Aff_Copy_Line2_B = $_POST['Aff_Copy_Line2_B'];
	$Aff_Bill_to_B = $_POST['Aff_Bill_to_B'];
	
	$Aff_Photo_Rider_C = $_POST['Aff_Photo_Rider_C'];
	$Aff_Copy_Line1_C = $_POST['Aff_Copy_Line1_C'];
	$Aff_Copy_Line2_C = $_POST['Aff_Copy_Line2_C'];	
	$Aff_Bill_to_C = $_POST['Aff_Bill_to_C'];
	
	$Aff_Photo_Rider_D = $_POST['Aff_Photo_Rider_D'];
	$Aff_Copy_Line1_D = $_POST['Aff_Copy_Line1_D'];
	$Aff_Copy_Line2_D = $_POST['Aff_Copy_Line2_D'];	
	$Aff_Bill_to_D = $_POST['Aff_Bill_to_D'];
	//Start Decal Orders
	$Aff_DecalType = $_POST['Aff_DecalType'];
	$Aff_Quantity_Regular_A = $_POST['Aff_Quantity_Regular_A'];
		$Aff_Name_Regular_A = $_POST['Aff_Name_Regular_A'];
		$Aff_Contact_Regular_A = $_POST['Aff_Contact_Regular_A'];	
	$Aff_Quantity_Regular_B = $_POST['Aff_Quantity_Regular_B'];
		$Aff_Name_Regular_B = $_POST['Aff_Name_Regular_B'];
		$Aff_Contact_Regular_B = $_POST['Aff_Contact_Regular_B'];	
	$Aff_Quantity_Regular_C = $_POST['Aff_Quantity_Regular_C'];
		$Aff_Name_Regular_C = $_POST['Aff_Name_Regular_C'];
		$Aff_Contact_Regular_C = $_POST['Aff_Contact_Regular_C'];		

$Aff_Comments = $_POST['Aff_Comments'];	
//End F.C. Tucker Affiliate
	
//Information about the user
$userBrowser = $_SERVER['HTTP_USER_AGENT'];	
$ip = $_SERVER['REMOTE_ADDR'];
	
// Build the email (replace the address in the $to section with your own)
$to = 'dwilliams@talktotucker.com' . ', ';
//$to .= 'signs@itucker.com' . ', ';
//$to .= 'redirections@itucker.com' . ', ';
$to .= 'ehiggins@talktotucker.com' . ', ';
$to .= $email;
//Send e-mail only to April for Custom Rider photos
if ($Photo_Rider_A or $Photo_Rider_B or $Photo_Rider_C or $Photo_Rider_D or $Aff_Photo_Rider_A or $Aff_Photo_Rider_B or $Aff_Photo_Rider_C or $Aff_Photo_Rider_D != "") {
$to .= ', ' . 'aleas@talktotucker.com';
}	   
$subject = "New Sign & Decal Order From: $name";
//Message build for Metro Office based on submit button
if($OfficeName == "Carmel" or $OfficeName == "Castleton" or $OfficeName == "East" or $OfficeName == "Fishers" or $OfficeName == "Keystone at the Crossing" or $OfficeName == "Meridian North/9277" or $OfficeName == "Meridian North/9279" or $OfficeName == "Noblesville" or $OfficeName == "Northeast" or $OfficeName == "South" or $OfficeName == "Suburban North" or $OfficeName == "9201 Group" or $OfficeName == "West" or $OfficeName == "Zionsville" or $OfficeName == "Corporate 9279" ) {
	$message = "--Metro Office Order Information--	
	Office:		$OfficeName
	Order Date: 	$date
	Delivery Date:	$deliveryDate
	Ordered By:	 $name
	Email:	$email
	Phone Number:  $phoneNumber
	Street Address:  $address
	City, State, Zip:  $cityStateZip			
	
--F.C. Tucker Metro Signs--
	'T' Open House Yard Signs: $Open_House_Yard_Signs
	Large SOLD Rider: $Sold_Rider
	
	Open House Sign Rider
		12-2pm:  $tweleveTOtwo
		12-2pm & 3-5pm:  $tweleveTOtwoANDthreeTOfive
		12-3pm:  $tweleveTOthree
		12-4pm:  $tweleveTOfour
		12-5pm:  $tweleveTOfive
		 1-3pm:  $oneTOthree
		 1-4pm:  $oneTOfour
		 1-5pm:  $oneTOfive
		 2-4pm:  $twoTOfour
		 2-5pm:  $twoTOfive
		 3-5pm:  $threeTOfive
		 
	U-Bracket:  $U_Bracket
	Adapter: $Adapter
	'T' Tucker Yard Sign: $Metro_Yard_Sign	
	Condo Window Signs: $Condo_For_Sale
	
	Photo Rider or Custom Verbiage  Rider 1
		Quantity:     $Photo_Rider_A	
		Copy Line 1:  $Copy_Line1_A
		Copy Line 2:  $Copy_Line2_A		
		Bill to:      $Bill_to_A
	Photo Rider or Custom Verbiage  Rider 2
		Quantity:     $Photo_Rider_B	
		Copy Line 1:  $Copy_Line1_B
		Copy Line 2:  $Copy_Line2_B		
		Bill to:      $Bill_to_B
	Photo Rider or Custom Verbiage  Rider 3
		Quantity:     $Photo_Rider_C	
		Copy Line 1:  $Copy_Line1_C
		Copy Line 2:  $Copy_Line2_C		
		Bill to:      $Bill_to_C
	Photo Rider or Custom Verbiage  Rider 4
		Quantity:     $Photo_Rider_D	
		Copy Line 1:  $Copy_Line1_D
		Copy Line 2:  $Copy_Line2_D		
		Bill to:      $Bill_to_D
	
	--Decals--
	Decal Type: $DecalType
	Set 1 
		Quantity: $Quantity_Regular_A
		Agent Name: $Name_Regular_A
		Agent Contact: $Contact_Regular_A
		
	Set 2
		Quantity: $Quantity_Regular_B
		Agent Name: $Name_Regular_B
		Agent Contact: $Contact_Regular_B
		
	Set 3
		Quantity: $Quantity_Regular_C
		Agent Name: $Name_Regular_C
		Agent Contact: $Contact_Regular_C

	Comments: $comments					
	
	Time: $time
	Browser: $userBrowser
	IP:   $ip
	";
}	
//Message build for Affiliate office based on submit button
if($OfficeName == "Anderson" or $OfficeName == "Anderson Commercial" or $OfficeName == "Auburn" or $OfficeName == "Bloomington" or $OfficeName == "Columbus" or $OfficeName == "Crawfordsville" or $OfficeName == "Evansville Commercial" or $OfficeName == "Evansville - Eagle Crest" or $OfficeName == "Evansville - East Virginia" or $OfficeName == "Evansville - Pearl" or $OfficeName == "Ft. Wayne" or $OfficeName == "Ft. Wayne - Illinois" or $OfficeName == "Goshen" or $OfficeName == "Greencastle" or $OfficeName == "Henderson KY" or $OfficeName == "Jasper" or $OfficeName == "Kokomo" or $OfficeName == "Lafayette" or $OfficeName == "Lafayette Commercial" or $OfficeName == "Marion" or $OfficeName == "Muncie" or $OfficeName == "New Albany" or $OfficeName == "Newburgh" or $OfficeName == "Pendleton" or $OfficeName == "Princeton" or $OfficeName == "Rensselaer" or $OfficeName == "Seymour" or $OfficeName == "Shelbyville" or $OfficeName == "South Bend" or $OfficeName == "Terre Haute" or $OfficeName == "Valparaiso" or $OfficeName == "Vincennes") {
	$message = "--Affilitate Office Order Information--
	Office:		$OfficeName
	Order Date:		$date
	Delivery Date:	$deliveryDate
	Ordered By:		$name
	Email:		$email
	Phone Number:	$phoneNumber
	Street Address:   $address
	City, State, Zip: $cityStateZip		
		
--F.C. Tucker Affiliate Signs--
	'T' Open House Yard Signs: $Aff_Open_House_Yard_Signs
	Large SOLD Rider: $Aff_Sold_Rider
	
	Open House Sign Rider
		12-2pm:  $Aff_tweleveTOtwo
		12-2pm & 3-5pm:  $Aff_tweleveTOtwoANDthreeTOfive
		12-3pm:  $Aff_tweleveTOthree
		12-4pm:  $Aff_tweleveTOfour
		12-5pm:  $Aff_tweleveTOfive
		 1-3pm:  $Aff_oneTOthree
		 1-4pm:  $Aff_oneTOfour
		 1-5pm:  $Aff_oneTOfive
		 2-4pm:  $Aff_twoTOfour
		 2-5pm:  $Aff_twoTOfive
		 3-5pm:  $Aff_threeTOfive
		 
	U-Bracket:  $Aff_U_Bracket
	Adapter: $Aff_Adapter
	
	'T' Tucker Yard Sign: $Aff_Yard_Sign
		Affiliate Office Name: $Aff_Yard_Sign_Name
		Affiliate Office Number: $Aff_Yard_Sign_Number	
		
	Stock Verbiage Rider: $Aff_Stock_Verbiage_Rider
	Condo Window Signs: $Aff_Condo_For_Sale
	Affiliate Direction Signs: $Aff_Directional_Sign
	Affiliate Open House Directional Sign: $Aff_Open_House_Directional_Sign
	
	Photo Rider or Custom Verbiage  Rider 1
		Quantity:     $Aff_Photo_Rider_A	
		Copy Line 1:  $Aff_Copy_Line1_A
		Copy Line 2:  $Aff_Copy_Line2_A		
		Bill to:      $Aff_Bill_to_A
	Photo Rider or Custom Verbiage  Rider 2
		Quantity:     $Aff_Photo_Rider_B	
		Copy Line 1:  $Aff_Copy_Line1_B
		Copy Line 2:  $Aff_Copy_Line2_B		
		Bill to:      $Aff_Bill_to_B
	Photo Rider or Custom Verbiage  Rider 3
		Quantity:     $Aff_Photo_Rider_C	
		Copy Line 1:  $Aff_Copy_Line1_C
		Copy Line 2:  $Aff_Copy_Line2_C		
		Bill to:      $Aff_Bill_to_C
	Photo Rider or Custom Verbiage  Rider 4
		Quantity:     $Aff_Photo_Rider_D	
		Copy Line 1:  $Aff_Copy_Line1_D
		Copy Line 2:  $Aff_Copy_Line2_D		
		Bill to:      $Aff_Bill_to_D
		
	--Decals--
	Decal Type: $Aff_DecalType
	Set 1 
		Quantity: $Aff_Quantity_Regular_A
		Agent Name: $Aff_Name_Regular_A
		Agent Contact: $Aff_Contact_Regular_A
		
	Set 2
		Quantity: $Aff_Quantity_Regular_B
		Agent Name: $Aff_Name_Regular_B
		Agent Contact: $Aff_Contact_Regular_B
		
	Set 3
		Quantity: $Aff_Quantity_Regular_C
		Agent Name: $Aff_Name_Regular_C
		Agent Contact: $Aff_Contact_Regular_C
					
	Comments: $Aff_Comments	
		
	Time: $time
	Browser: $userBrowser
	IP:   $ip	
	";	
}

$headers = " : From $email";


// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);

// Redirect
header("Location: signRedirect.htm");
?>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perhaps I missed something, but I do not think this is a bulk email application.

Since you are only interested in sending a few emails, you might find that the PHP mail() command is easier to learn and use than PHPMAILER.  

If you're one of the few remaining individuals who insist on sending his own bulk email, PHPMAILER might be useful.  But I would choose Constant Contact over PHPMAILER any day.  It's mostly a question of what your time is worth.

Anyway, this has been hanging out there for a while now.   Please post back if you still have any questions.

bet regards, ~Ray