473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Need help with sending HTML formatted emails

Here is my code for formatting an HTML email. I know that spinning
through the $_POST array as I am isn't very pretty but it's a long
list so for now I'm using this approach. The problem is that despite
setting the Content-type the resulting email arrives in plain text.
Outlook 2003 is my email client and I receive HTML emails without a
problem.

Can someone please advise me on what I'm doing wrong?

$to_address = "to@mysite.com";
$from_address = "we*****@mysite.com";
$subject = "Evaluation Request";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: $from_address\r\n";
$message = "";
foreach ( $_POST as $key =$value ) {
$message.= "<b>" . $key . "</b>" . " " . ":" . " " . $value . "<br /
>";
};
$_SESSION['sent_message'] = "Thank you for your request! Someone will
be contacting you soon.";
mail($to_address, $subject, $message, $headers);
header = ("location: index.php");

Thank you!
- Tim

Oct 1 '07 #1
2 1695
On Sep 30, 10:16 pm, Big Moxy <bigm...@gmail.comwrote:
Here is my code for formatting an HTML email. I know that spinning
through the $_POST array as I am isn't very pretty but it's a long
list so for now I'm using this approach. The problem is that despite
setting the Content-type the resulting email arrives in plain text.
Outlook 2003 is my email client and I receive HTML emails without a
problem.

Can someone please advise me on what I'm doing wrong?

$to_address = "t...@mysite.com";
$from_address = "webm...@mysite.com";
$subject = "Evaluation Request";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From: $from_address\r\n";
$message = "";
foreach ( $_POST as $key =$value ) {
$message.= "<b>" . $key . "</b>" . " " . ":" . " " . $value . "<br />";
};

$_SESSION['sent_message'] = "Thank you for your request! Someone will
be contacting you soon.";
mail($to_address, $subject, $message, $headers);
header = ("location: index.php");

Thank you!
- Tim
NEVER MIND! My emails are taking longer to arrive than expected.
However I received a plain text email after I had changed my code so
that the headers were set before creating the message and just assumed
there still was a problem. However after my post a new email arrived
an it was formatted as expected.

Oct 1 '07 #2
Big Moxy <bi*****@gmail.comwrote:
>
Here is my code for formatting an HTML email. I know that spinning
through the $_POST array as I am isn't very pretty but it's a long
list so for now I'm using this approach. The problem is that despite
setting the Content-type the resulting email arrives in plain text.
What do you mean by that? Do you mean you see the HTML tags?
>Outlook 2003 is my email client and I receive HTML emails without a
problem.
Most HTML emails come in as Content-Type: multipart/alternative with a
text/html section and a text/plain section. However, what you describe
should work. Have you tried wrapping the HTML with <htmland <bodytags?
$message.= "<b>" . $key . "</b>" . " " . ":" . " " . $value . "<br /
>>";
Why would you do it that way, instead of the much more efficient:
$message.= "<b>$key</b: $value<br/>";
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dan glenn | last post by:
I'm creating HTML emails from a PHP site and sending them out to an email list (just about 40 people so far are on this list). I've tested and confirmed that these emails work in yahoo.com's...
5
by: Paul Lamonby | last post by:
Hi, I am generating a HTML formatted email in PHP, but I am getting the most bizarre error, it will randomly delete characters out of the HTML code while in transit to the address, therefore...
5
by: D. Alvarado | last post by:
Hello, DOes anyone have a recommendation for some free code to send out HTML-formatted emails? The code does not have to be cross-browser compatible. Thanks for any advice, - Dave
1
by: Ian Taylor | last post by:
Hi all... Is it possible to send RTF-formatted emails using the .NET SmtpMail implementation? I can only find provision in the BodyFormat property of the message to send plain text or HTML...
2
by: Paul Turley | last post by:
Does anyone have some sample code for sending an HTML formatted message using CDONTS? Thanks RE: Sending HTML formatted mail using CDONTS -- Paul Turley, MCSD, MCAD, MCT, MSF...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
7
by: Ray Booysen | last post by:
Hi all I'm sending email via ASP.NET in HTML mode. Each email has exactly one attachment and I do have full access to the SMTP server. However, if I send the email in HTML format, the...
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 Can anyone recommend any good freeware that will allow me to send an HTML formatted email with an attachment? The attachment will also be an HTML file, but it would...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.