papapax Posted June 11, 2008 Share Posted June 11, 2008 Hi, I have been struggling for a while to figure out how to send a simple HTML confirmation mail with our company logo attached at the head and a short, thanks for booking etc. message in the body and a signature at the foot. Currently the form is working fine but only sends text email confirmations. I am predominantly a web designer that inherited the project, I managed to get it working up to this point, but have been stumped on how to get the response confirmation mail to send in HTML. Any help would be appreciated, the code is attached. Kind Regards, Frank the code follow: [<?php <!--- Needed for fasthosts --------> ini_set("sendmail_from", "[email protected]"); // Receiving variables @$title = addslashes($_POST['title']); @$username = addslashes($_POST['username']); @$surname = addslashes($_POST['surname']); @$email = addslashes($_POST['email']); @$phone = addslashes($_POST['phone']); @$postcode = addslashes($_POST['postcode']); @$guests = addslashes($_POST['guests']); @$dateinput = addslashes($_POST['dateinput']); @$time = addslashes($_POST['time']); @$enquiry = addslashes($_POST['enquiry']); //Sending Email to form owner $pfw_header = "From: $email\n" . "Reply-To: $email\n"; $pfw_subject = "Tapa Tapa booking Enquiry"; $pfw_email_to = "[email protected]"; $pfw_message = "Title: $title\n" . "First Name: $username\n" . "Surname: $surname\n" . "email: $email\n" . "Phone Number: $phone\n" . "Postcode: $postcode\n" . "Number of guests: $guests\n" . "Date: $dateinput\n" . "Time: $time\n" . "Additional enquiry: $enquiry\n"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; //Sending auto respond Email to visitor $pfw_header = "From: [email protected]\n" . "Reply-To: [email protected]\n"; $pfw_subject = "Your Tapa Tapa booking enquiry received"; $pfw_email_to = "$email"; $pfw_message = "Dear $username,\n" . "\n" . "Thank you for your booking enquiry, please note this is not a confirmed reservation we shall be in touch to confirm shortly.\n" . "\n" . "Kind Regards,\n" . "The Tapa Tapa Team"; @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; //saving record in a text file $pfw_file_name = "velvetcard.csv"; $pfw_first_raw = "title,username,surname,email,phone,postcode,guests,dateinput,time,enquiry\r\n"; $pfw_values = "$title,$username,$surname,$email,$phone,$postcode,$guests,$dateinput,$time,$enquiry\r\n"; $pfw_is_first_row = false; if(!file_exists($pfw_file_name)) { $pfw_is_first_row = true ; } if (!$pfw_handle = fopen($pfw_file_name, 'a+')) { die("Cannot open file ($pfw_file_name)"); exit; } if ($pfw_is_first_row) { if (fwrite($pfw_handle, $pfw_first_raw ) === FALSE) { die("Cannot write to file ($pfw_filename)"); exit; } } if (fwrite($pfw_handle, $pfw_values) === FALSE) { die("Cannot write to file ($pfw_filename)"); exit; } fclose($pfw_handle); $confirmation = true; header('Location: reservation.html?confirmation'); ?>] Link to comment https://forums.phpfreaks.com/topic/109708-html-confirmation-email/ Share on other sites More sharing options...
Vizor Posted June 11, 2008 Share Posted June 11, 2008 To send HTML emails you need to set the content-type headers. $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Link to comment https://forums.phpfreaks.com/topic/109708-html-confirmation-email/#findComment-562945 Share on other sites More sharing options...
monkeytooth Posted June 11, 2008 Share Posted June 11, 2008 To send HTML emails you need to set the content-type headers. $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers... defined before mail() function, might help too... Link to comment https://forums.phpfreaks.com/topic/109708-html-confirmation-email/#findComment-562947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.