Log in

View Full Version : Formatting autoreply e-mails



marynorn
02-08-2008, 01:51 PM
I have a form that sends out an autoreply, but at the moment it's just text. I'd like it to display an image at the top, and use a better font than the default. Every time I try to edit the autoreply, I end up with error messages, so any help here would be appreciated.

<?php
$to = "repairs@myemail.co.uk" ;
$name = $_REQUEST['name'] ;
$headers = "From: " . $_REQUEST['email'] . "\n" ;
$subject = "Repair Request Form";
$from = $_REQUEST['email'] ;

$fields = array();
$fields{"name"} = "Tenant Name";
$fields{"houseNumber"} = "House Name";
$fields{"address1"} = "Address Line 1";
$fields{"address2"} = "Address Line 2";
$fields{"address3"} = "Address Line 3";
$fields{"postcode"} = "Postcode";
$fields{"optone"} = "Type of Repair";
$fields{"opttwo"} = "Problem";
$fields{"details"} = "Details of Problem";
$fields{"email"} = "E-mail Address";
$fields{"dayphone"} = "Daytime Phone Number";
$fields{"mobphone"} = "Mobile Phone Number";
$fields{"mondayam"} = "Monday AM Repair";
$fields{"tuesdaypm"} = "Tuesday PM Repair";
$fields{"wednesdaypm"} = "Wednesday PM Repair";
$fields{"thursdayam"} = "Thursday AM Repair";
$fields{"fridayam"} = "Friday AM Repair";
$fields{"accessarrangements"} = "Access Arrangements";


$body = "Repair Request Information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$headers2 = "From: repairs@myemail.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for using our On Line Repairs Service. The details of your request are listed below, and we will contact you within one working day to arrange your repair.\n\n"; foreach($fields as $a => $b){ $autoreply .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
?>

jackbenimble4
02-09-2008, 03:16 AM
For displaying an image or changing the font, you need to use HTML. For more information on HTML and Emails here's an article: How to Code HTML Email Newsletters (http://www.sitepoint.com/article/code-html-email-newsletters/)

If that article doesn't satisfy you, just search google for more HTML & Email articles. An email isn't as easy to write beautifully as a webpage. There's some quirks that are exclusive to e-mails involving CSS and the differences in which the e-mails are rendered. You should definitely be able to accomplish your goal though with just about any tutorial on the subject.