morgaknutson Posted May 15, 2007 Share Posted May 15, 2007 Hey there, I know very little about php. Any help is much appreciated. I'm going from an already written script. I needed to change the MIME type to HTML, so I could email a link. When I changed the MIME type the From variable stopped working. Here's the code: <?php include '../header.php'; function sendEmail($to, $subject, $content, $headers, $mailserver = null) { $headers = 'Content-Type: text/html; charset=UTF-8' . 'From: ' . $headers['From'] . "\r\n" . 'Reply-To: ' . $headers['From'] . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $content, $headers); } function openDatabase() { mysql_connect("localhost","----------_admin","Got23O"); if (mysql_select_db("--------_marketing")) return TRUE; else return FALSE; } function closeDatabase() { if (mysql_close()) return TRUE; else return FALSE; } $errorMessage = ''; $success = false; if (isset($_REQUEST['Submit'])) { $First_Name = mysql_escape_string($_REQUEST['First_Name']); $Last_Name = mysql_escape_string($_REQUEST['Last_Name']); $Address = mysql_escape_string($_REQUEST['Address']); $City = mysql_escape_string($_REQUEST['City']); $State = mysql_escape_string($_REQUEST['State']); $Zip = mysql_escape_string($_REQUEST['Zip']); $Day_Phone = mysql_escape_string($_REQUEST['Day_Phone']); $Eve_Phone = mysql_escape_string($_REQUEST['Eve_Phone']); $Email = mysql_escape_string($_REQUEST['Email']); $Confirm_Email = mysql_escape_string($_REQUEST['Confirm_Email']); $Project = mysql_escape_string($_REQUEST['Project']); $Stories = mysql_escape_string($_REQUEST['Stories']); $Footage = mysql_escape_string($_REQUEST['Footage']); $Bedrooms = mysql_escape_string($_REQUEST['Bedrooms']); $Price = mysql_escape_string($_REQUEST['Price']); $Married = mysql_escape_string($_REQUEST['Married']); $Children = mysql_escape_string($_REQUEST['Children']); $Age = mysql_escape_string($_REQUEST['Age']); $Income = mysql_escape_string($_REQUEST['Income']); $Purchase_in = mysql_escape_string($_REQUEST['Purchase_in']); $Occupancy = mysql_escape_string($_REQUEST['Occupancy']); $Household = mysql_escape_string($_REQUEST['Household']); $Retired = mysql_escape_string($_REQUEST['Retired']); $Garage = mysql_escape_string($_REQUEST['Garage']); $Golfcart = mysql_escape_string($_REQUEST['Golfcart']); $Please_Contact = mysql_escape_string($_REQUEST['Please_Contact']); $Contact_Method = mysql_escape_string($_REQUEST['Contact_Method']); $Golfers = mysql_escape_string($_REQUEST['Golfers']); $Hear_about_us = mysql_escape_string($_REQUEST['Hear_about_us']); $query = "insert into RequestForm set First_Name='$First_Name', Last_Name='$Last_Name', Street_Address='$Address', City='$City', State='$State', Zip='$Zip', Phone='$Day_Phone', Phone2='$Eve_Phone', email='$Email', Project='$Project', Housing_Type='$Stories', Square_Footage='$Footage', Bedrooms='$Bedrooms', Price_Range='$Price', Marital_Status='$Married', Children='$Children', Age='$Age', Income='$Income', Plan_to_Buy='$Purchase_in', Will_this_be_your='$Occupancy', Household_size='$Household', Retired='$Retired', Garage='$Garage', Golfcart='$Golfcart', Contact_Method='$Contact_Method', Golfers='$Golfers', Hear_about_us='$Hear_about_us', DateAdded=now()"; error_log($query); if (openDatabase()) { $result = mysql_query($query); if (mysql_affected_rows() == 1) { $success = true; $thankyou = <<<EOF <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Thank You</title> </head> Hello $First_Name,<br> <br> Thank you for joining the ----------- interest list. We look forward to providing you with updates as additional information becomes available. <br><br> Again, thank you for your interest! <br><br> Sincerely, <br><br> ---------- Companies <br><br><br> To unsubscribe, please <a href="http://www.---------------.com/mails/111706/unsubscribe/index.php?email=$Email">click here</a>. <body> </body> </html> EOF; //send email to individual sendEmail($Email, 'Thank You from -------------', $thankyou, array('From' => '[email protected]')); /* $inforequest = <<<EOF The following info was submitted: EOF; $inforequest .= "First Name: $First_Name\n"; $inforequest .= "Last Name: $Last_Name\n"; $inforequest .= "Address: $Address\n"; $inforequest .= "City: $City\n"; $inforequest .= "State: $State\n"; $inforequest .= "Zip: $Zip\n"; $inforequest .= "Day Phone: $Day_Phone\n"; $inforequest .= "Evening Phone: $Eve_Phone\n"; $inforequest .= "Email: $Email\n"; $inforequest .= "Project: $Project\n"; $inforequest .= "Stories: $Stories\n"; $inforequest .= "Square Footage: $Footage\n"; $inforequest .= "Bedrooms: $Bedrooms\n"; $inforequest .= "Price: $Price\n"; $inforequest .= "Marital Status: $Married\n"; $inforequest .= "Number of Children: $Children\n"; $inforequest .= "Age: $Age\n"; $inforequest .= "Total Income: $Income\n"; $inforequest .= "Purchase When: $Purchase_in\n"; $inforequest .= "Occupancy: $Occupancy\n"; $inforequest .= "Number of Household Members: $Household\n"; $inforequest .= "Retired: $Retired\n"; $inforequest .= "Garage: $Garage\n"; $inforequest .= "Golf Cart: $Golfcart\n"; $inforequest .= "Contact Method: $Contact_Method\n"; $inforequest .= "Number of Golfers: $Golfers\n"; $inforequest .= "How did you hear: $Hear_about_us\n"; $inforequest .= "\nThanks,\n"; $inforequest .= "The ------------ Form Robot"; //send email sendEmail('[email protected]', '------------.com Request For Info', $inforequest, array('From' => '[email protected]')); */ } closeDatabase(); } } ?> I striked out the name of the company with -------------. Thanks a lot. Link to comment https://forums.phpfreaks.com/topic/51552-from-and-content-types-in-mail-function/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.