GetDotted Domains

Viewing Thread:
"Sending HTML emails to Outlook..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Thu 02/06/05 at 17:08
Regular
"Pouch Ape"
Posts: 14,499
OK, I know it's generally considered a bad idea to send HTML emails, but a client wants it.

I've figured out how to send to Hotmail and get my images show, but not as attachments, using Mimetype (Mimes!), but they come out all wrong in Outlook - is there a special trick for doing this bad idea? Thanks.
Mon 20/06/05 at 10:50
Regular
"Pouch Ape"
Posts: 14,499
Right, well it finally works, thanks. I've got no idea why it wasn't before - for all intents and purposes it was exactly the same, just put together slightly differently. Are headers really that fickle?
Mon 20/06/05 at 02:38
Regular
"Devil in disguise"
Posts: 3,151
Try this...
This works both in thunderbird and outlook for me. At least if this doesn't work you can put it down to your client with more certainty.

$textemail="This is the text part of the message.\n";
$htmlemail="

Header

Paragraph

\n";
$subject="Test Email";
$to="Test ";
$from="HTML Tester ";
$mime_boundary="==Multipart_Boundary_sjs48643ik";
$headers = "From: $from\n" .
"Reply-to: $from\n".
"X-Mailer: PHP Mail\n".
"MIME-Version: 1.0\n" .
"Content-Type:multipart/alternative;\n" .
" boundary=\"".$mime_boundary."\"\n";

$message = "This is a multi-part message in MIME format.\n\n" .
"--".$mime_boundary."\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$textemail .
"--".$mime_boundary."\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$htmlemail;
if (mail($to, $subject, $message, $headers))
echo "Email Sent!";
else
echo "Failed to send message.";
Sun 19/06/05 at 21:38
Regular
"Pouch Ape"
Posts: 14,499
I'm sure this bit is the problem:

Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

They are the headers to the plain text part, and show up in Outlook with the plain text message. The boundaries blatantly work because they successfully split the message up into it's alternative parts.
Sun 19/06/05 at 21:36
Regular
"Pouch Ape"
Posts: 14,499
*POP*

This is really annoying now, as it'll start holding up a couple of projects if it carries on much longer. The message source is fine, and as far as I can tell the rest of it is fine. But it refuses to work.

BUT!!!

I've had HTML emails forwarded to me that have worked in someone else's Outlook, and the headers, boundaries, etc. work in exactly the same way, but these messages haven't displayed as HTML in my Outlook either. It's set to HTML. Hate to admit it, but I'm stumped.
Thu 09/06/05 at 21:31
Regular
"Pouch Ape"
Posts: 14,499
From looking at the mail source in Outlook, it's all in place as it should be. Just thought of something else I could try...

EDIT: Nah, still nothing doing. I built the headers up as you suggested, but it looks exactly the same in the message source. The problem lies when it's detecting the boundary for the plain text, but it's no different from the countless other examples I've seen.
Thu 09/06/05 at 21:13
Regular
"Devil in disguise"
Posts: 3,151
Well, I tried copy & pasting the code and sending a mail with it, certainly didnt give me HTML emails in thunderbird but thats possibly because its lost something in the copy & paste.

What I'd be tempted to do especially with the headers is rather than relying on 1 big multi-line string to put it all the information together is build it up line by line yourself and making sure you've got the correct number of linefeeds and spaces. eg

$headers = "From: $from\n";
$headers.= "MIME-Version: 1.0\n";

..and so on. Email clients are generally very unforgiving when it comes to parsing emails, an extra "\n" or a "\r" where it shouldn't be and it'll fall to pieces.

It could well be your email client thats the problem here too, but I guess that theory is easily tested.
Thu 09/06/05 at 18:03
Regular
"Pouch Ape"
Posts: 14,499
Looks a bit wrong there because of the line length, but it sends absolutely fine, works perfect in Hotmail, works perfect as just HTML in Outlook, and I've removed all remnants of the company.
Thu 09/06/05 at 18:02
Regular
"Pouch Ape"
Posts: 14,499
$message = "This is a multi-part message in MIME format.

--==MXCVS_73849576_REGIONFREE_NANU-NANU==
Content-Type: text/plain; charset=" . '"' . "iso-8859-1" . '"' . "
Content-Transfer-Encoding: 7bit

plain text content

--==MXCVS_73849576_REGIONFREE_NANU-NANU==
Content-Type: text/html; charset=" . '"' . "iso-8859-1" . '"' . "
Content-Transfer-Encoding: 7bit

HTML text content

--==MXCVS_73849576_REGIONFREE_NANU-NANU==--"

mail("$this_email", "$subject", "$message",
"Date: $page_date, $page_time \n" .
"Return-Path: Newsletter \n" .
"From: Newsletter \n" .
"Organization: Muh \n" .
"X-Mailer: PHP 4.3.11 \n" .
"MIME-Version: 1.0 \n" .
"Content-Type: multipart/alternative; boundary=" . '"' . "==MXCVS_73849576_REGIONFREE_NANU-NANU==" . '"' . " \n\n");
Thu 09/06/05 at 17:50
Regular
"Pouch Ape"
Posts: 14,499
You on MSN Garin?

I'm sure it's not the code. Although that means that it probably is.
Thu 09/06/05 at 16:48
Regular
"Devil in disguise"
Posts: 3,151
All I can suggest is...show us some code.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Top-notch internet service
Excellent internet service and customer service. Top-notch in replying to my comments.
Duncan
LOVE it....
You have made it so easy to build & host a website!!!
Gemma

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.