Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Problem sending HTML messages with MIME::Lite to Hotmail

Posted on 2004-04-26
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

mishagale earned 1500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
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…
Six Sigma Control Plans

721 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