Problem sending HTML messages with MIME::Lite to Hotmail

Posted on 2004-04-26
Last Modified: 2011-10-03
Hi there people.

I have a problem on using MIME::Lite (3.01) to send HTML messages. The problem is that no matter what I do I cannot get these messages to display in Hotmail.

Currently the code for sending my HTML message is as follows:

$msg = MIME::Lite->build(       From    => $from,
                                  Sender  => $acc_reply_email,
                                  To      => $to,
                                  Cc      => $cc,
                                  Bcc     => $bcc,
                                  ReplyTo => $acc_reply_email,
                                  Subject => $subject,
                                  ReturnPath => $acc_reply_email,
                                  Type    => "multipart/related");

  #Attach message data
  $msg->attach(    Type => "text/html",
                   Data => $message,
                   Encoding => "7bit");

$message is just a correctly formed HTML document.

Messages sent using this method display perfectly in offline clients such as Outlook, other web based email systems such as Yahoo, my own mail reader at Net my and other web based email readers like mail2web.

Yet for some reason, although the header information (to, from, subject) is displayed correctly in Hotmail, the message pane is completely blank.

If $msg->attach is used to attach files to the message, these are listed correctly in Hotmail however the message still remains blank.

I have also tried using the following code:

$msg = MIME::Lite->build(       Type     => "text/html",
                                  Encoding => "7bit",
                                  From    => $from,
                                  Sender  => $from,
                                  To      => $to,
                                  Subject => $subject,
                                  Data    => $message);

Again this method works for other clients but the message pane remains blank in Hotmail. I read somewhere a suggestion of calling $msg->scrub before sending the message but this made no difference at all.

Incidentally we also offer the option to send plain text messages using the following code:

  $msg = MIME::Lite->build(       Type => "text/plain",
                                  From    => $from,
                                  Sender  => $acc_reply_email,
                                  To      => $to,
                                  Cc      => $cc,
                                  Bcc     => $bcc,
                                  ReplyTo => $acc_reply_email,
                                  Subject => $subject,
                                  ReturnPath => $acc_reply_email,
                                  Data    => $message);

Plain text messages sent using this method display perfectly in Hotmail (as well as other email clients).

This is getting to be a bit frustrating as every other HTML message from other systems I receive in Hotmail (including some which I’m sure aren’t properly formed) seem to display without any problems yet the messages I’m sending (which I believe to be MIME compliant and properly formed) do not display.

Obviously this is also a problem for the many users there are at Net my, many of whom I’m sure would like to be able to send HTML messages to Hotmail accounts.

I couldn’t find any reference to this problem in the MIME::Lite POD, nor much useful on Google hence my reason for asking here. If anyone has had this problem and managed to overcome it I’d be very grateful indeed for a solution.

Due to the number of points on offer I’d prefer not to see “use xxx module instead of MIME::Lite” answers. A genuine solution to my problem is what I’m after.

Thanks very much in advance.
Question by:jb69

Accepted Solution

mishagale earned 500 total points
ID: 10917543
Could you show us an the complete source of an example message from your program, along with the source of a message which *does* work with hotmail, so we can perhaps see what the difference is? Have you checked the HTML source of the pages hotmail uses to display your e-mails? It may just be that hotmail is providing the HTML from your message, but there is some conflict between the HTML and/or CSS already on the page, and your HTML.

Author Comment

ID: 10918103
Argh, I don't believe this.

I had a look at the source and as I had seen before Hotmail wasn't displaying any of the readable HTML message. However it was managing to pull the header style information.

I had another look at the HTML being sent and all that was wrong was that I hadn't closed my head tag properly (it was missing the / in the second <head> for some reason). Although Hotmail doesn't display these tags it must have been throwing off the parsing of the message.

Anyway, I fixed that and now it works.

It's funny how every other email reader had no problem with this slight error in HTML but it it made Hotmail fall over completely!

Anyway mishagale, you can have the points for inspiring me to look again at the HTML code displayed. It's not like I need them as I don't come here often :)


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now