hi,
I am trying to complete a script that sends an email along with html, the html changes the colors and the font, positions ...etc.
I am in need of help.
thnx in advance
hi,
I am trying to complete a script that sends an email along with html, the html changes the colors and the font, positions ...etc.
I am in need of help.
thnx in advance
Just simply add the html headers to the headers field. Below is a basic example:
// HTML headers
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//now to send it
mail($to, $subject, $message, $headers);
Hope it answers your question.
I'd recommend finding a good php library that allows for SMTP authentication. If the email client has decent security, php's plain old mail function with html headers is a sure fire way to get your email tossed in the junk folder. I use class.phpmailer.php. It also creates a plain text message for clients that don't allow html.
thnx cwarn23 it worked,
as for the class.phpmailer.php, should I put both versions (plain text And HTML) together in the mail? and what about the HTML tags, how can I make them disappear?
you could try this
<?
error_reporting(7);
$subject = $_POST['subject'];
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$email = $_POST['email'];
$country = $_POST["country"];
$telephone = $_POST["telephone"];
$message = $_POST['message'];
header("Location: thankyou.php");
$to = "$email";
$subject = "$firstname Confirmation Of Your Inquiry At WEBSITE NAME";
$MsgHeader = "From: WEBSITE NAME <noreply@website.com>\n";
$MsgHeader .= "MIME-Version: 1.0\n";
$MsgHeader .= "Content-type: text/html; charset=iso-8859-1";
$MsgBody = "
<html>
<head>
<title>$firstname Your Inquiry</title>
</head>
<body>
<table style='padding-left:0px' style='padding-top:0px'>
<tr><td align='left'><img src='http://www.website.com/pix/apalogo.jpg'></td></tr>
</table>
<table style='margin-left:12px'>
<tr><td> </td></tr>
<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Dear $firstname $lastname,</font></td></tr>
<tr><td> </td></tr>
<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Your inquiry has been received by WEBSITE NAME.</font></td></tr>
<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>A representative shall be in contact with you shortly to deal with your inquiry.</font></td></tr>
<tr><td> </td></tr>
<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>Best Regards</font></td></tr>
<tr><td> </td></tr>
<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>WEBSITE NAME Team</font></td></tr>
<tr><td> </td></tr>
<tr><td><font style='font-size: 11px' style='font-family: Tahoma, Arial'>This message has been automatically generated please do not reply.</font></td></tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</table>
<table style='margin-left:12px' style='margin-right:250px'>
<tr><td><font style='color: #336699' style='font-size: 10px' style='font-family: Tahoma, Arial'>This message, and any attachments, is intended only for the use of the individual or entity to which it is addressed, and may contain confidential, proprietary and/or privileged information that is exempt from disclosure under applicable law which is not waived or lost by any transmission failure.
If the reader of this message is not the intended recipient or its employee, or agent responsible for delivering the message to the intended recipient, you are hereby notified that any use, dissemination, distribution or copying of this communication and any attachments hereto is strictly prohibited.
If you have received this communication in error, please destroy this message.
Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of another person or entity.</font></td></tr>
</table>
</body>
</html>";
mail($to, $subject, $MsgBody, $MsgHeader);
exit;
?>
thank you very much, this was really helpful
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.