View Full Version : Configure The Display Of An Email Via Form Mailer
cottoneye1256
07-27-2007, 04:30 AM
I set up an form mailer which emails data to a company that a customer fills out, that works fine.
What I want is change the way the email looks so it's not so plain
ex: change the size and color of fonts of the data, add background color, add company logo....
below is the code I wrote that emails customers data, from, to, subject info:
<?php
//start building the mail string
$msg .="A free estimate has been requested from www.mywebsite.com\n\n";
$msg2 .="Thank you for requesting a free estimate. A specialist will contact you within 24 hrs.\n\n";
$msg2 .="You are receiving this email because you signed up for a free pest estimate from www.mywebsite.com.\n";
$msg2 .="Please do not reply to this e-mail. This message came from an automated mailbox.\n\n";
$msg2 .="Ace Plumbing (555)555-555\n\n";
$msg .= "FIRST NAME: $_POST[name]\n";
$msg .= "LAST NAME: $_POST[last]\n";
$msg .= "ADDRESS: $_POST[address]\n";
$msg .= "ADDRESS 2: $_POST[address2]\n";
$msg .= "CITY: $_POST[city]\n";
$msg .= "ZIP CODE: $_POST[zip]\n";
$msg .= "HOME PHONE: $_POST[homefone]\n";
$msg .= "ALTERNATE PHONE: $_POST[altfone]\n";
$msg .= "E-MAIL: $_POST[email]\n";
$msg .= "PREFERRED CONTACT: $_POST[preferred_contact]\n";
$msg .= "PROBLEM: $_POST[stateDropDown]\n";
$msg .= "MESSAGE: $_POST[message]\n";
$msg .= "NOTIFIED ABOUT FUTURE OFFERS: $_POST[notify_future_offers]\n";
$msg .= "\n";
//set up the mail
$recipient = "company@name.com";
$recipient2 = "$_POST[email]";
$subject = "Free Estimate Requested";
$mailheaders = "From: ace-plumbing.com<estimate@ace.com> \n";
$mailheaders .= "Reply-To: $_POST[email]\n\n";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
mail($recipient2, $subject, $msg2, $mailheaders);
//end of PHP code
?>
thank you
Change the headers to reflect html email and do some html formatting.
cottoneye1256
07-27-2007, 09:11 PM
I know who to write html but how do you set up the mailer so that it sends the changes I want.
If I just write the codes it displays it on the current page.
What I don't know is the special PHP codes that go before the html code.
any way you could give one example such as font colors
thank you
add this to your mail header
$mailheaders = 'MIME-Version: 1.0' . "\r\n";
$mailheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
cottoneye1256
07-30-2007, 02:05 AM
thanks but I didn't know where to put the $mailheader code?? and the html code? do I put any special codes in front of html? I kept getting errors where ever I put it so I kind of rewrote another set of codes.
Now how do I insert this variable into the html code so that the word "E-MAIL" is one color and the displayed email address is bold.
The variable $_POST[email] is an email address that someone would submit in a mail form.
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
INSERT THE VARIABLE HERE..........E-MAIL: $_POST[email]
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
thanks again
sorry for being a P.I.A. (pain in azz)
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
'.$_POST[email].'
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
cottoneye1256
07-30-2007, 02:40 AM
Thank you !!!!
I racked my brains out trying to figure it out on my own w/o asking for help.
and all it was this code before and after '.
thanks alot
in PHP the "." is a way to concat (combine) strings.
cottoneye1256
08-02-2007, 02:33 AM
sorry but I have one more prob...
I want to pass on the date and time the form was filled out and include it in the email.
I tried $date_time = date("m/d/y G.i:s", $time); but got an err message.
I also inserted this line with the other code but that didn't work either.
<font size="2" color="#414141" face="times new roman">DATE/TIME SERVICE CALL LOGGED:*</font><b> '.$_POST[date_time].'</b><br>
I need to some how assign a variable so it will display this in the email sent out to us:
DATE/TIME SERVICE CALL LOGGED: 08/01/07 17.21:02
I believe it should be near the mail function.
also...this works on html but not in the email
<?php
$time = time();
print "DATE/TIME SERVICE CALL LOGGED:*";
print date("m/d/y G.i:s", $time);
print "<br>"
?>
thanks again
"print" sends it to the screen. Which you arent doing. You need to put that in the message body like the rest of it.
$time = time();
$message .= "DATE/TIME SERVICE CALL LOGGED: ";
$message .= date("m/d/y G.i:s", $time);
$message .= "<br>"
cottoneye1256
08-02-2007, 01:32 PM
your going to kill me but I used a diff method of $message
I'm not using it in every line, just in the beginning and end.
I get stumped when I try to display the date and time after the birthday line within the code below.
If I really have to use $message in every line then that bring me back to my first question, how do I send an email so that it contains html and I can control the interface when sent, such as:
<tr><td>Joe</td><td>3rd</td><td>August</td><td>1970</td>'.$_POSTemail].' </tr>
If I put $message = <tr><td>Joe</td><td> It display it as text.
I tried different ways of inserting the date but I still errors parse error, unexpected '<'
Also when I tried out the time code I showed you the time is off by -3 hrs
sorry to bug you like this
thanks
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
'.$_POST[email].'
</tr>
</table>
</body>
</html>
';
not exactly sure where you want the date inserted, but here's an example
<?php
$time = time();
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>'.date("m/d/y G.i:s", $time).' </td>
'.$_POST[email].'
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
cottoneye1256
08-03-2007, 02:20 AM
Thanks again
I tried your example earlier only I put $time = time(); in the message area thats where I goofed
works great thanks
cottoneye1256
08-03-2007, 02:35 AM
NEVER MIND..it just clicked as to why...
The server I'm using is Godaddy which is located Arizona (MST) 3 hrs behind.
One quick question why is the time off by 3 hrs? Its 21:34 now but the time in the email shows 18:34
php is processed server side, time() gets the servers time, not yours.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.