in reply to HTML/Plain Text mail

I do this on a weekly basis, but with several hundred thousand emails :)

One thing I've found is that MIME support in email clients is very poor and you have to be careful what you send. We use tricks like putting invisible plain text at the top of the HTML so that people with broken clients can still read it. MIME::Lite is a handy module for simple MIME messages.

use MIME::Lite; my $msg = MIME::Lite->new(Type => 'multipart/alternative'); $msg->attach(Type => 'text/plain', Data => $msg_text); $msg->attach(Type => 'text/html', Data => $msg_html, Encoding = 'quote +d-printable'); $msg->scrub; $msg_mime = $msg->as_string;
The call to scrub seems to help it work a bit better. I prefer to use the Mail::Bulkmail module which makes it easy to send messages to multiple recipients.

Replies are listed 'Best First'.
Re(2): HTML/Plain Text mail
by dmmiller2k (Chaplain) on Jan 04, 2002 at 23:35 UTC

    Say gav^, you're not in any way responsible for some of the 40+ spams (over my several emails) I have to throw away each week, are you? :)

    dmm

Re: Re: HTML/Plain Text mail
by Anonymous Monk on Jan 05, 2002 at 00:38 UTC
    Thanks... Actually the process I am working on may potentially send out a few millions emails a week so performance is a huge concern. I have been using MIME::Lite and it is easy and works well. I found the 'multipart/alternative' flag in the Perldoc for Mime::Lite. My only question is that by using this approach you are potentially doubling the size of the email. Will this cause evil things to happen to the smtp server? Also, is there a way to compress the email?

    Thanks again,
    TAC
      Basically I split everything up into 4 messages:
      • Text people
      • AOL people, they get the text message but with the links/mailto's converted into HTML. This seems to give them clickable links which is nice.
      • HTML
      • Unknown people get MIME - use MIME::Lite to give them a multipart/alternative message.
      The text message tends to be pretty small, it's just a short bit of text to try to encourage somebody to go to a link. We work out if somebody is Text/HTML by embedding an invisible pixel in the email and giving them a couple of mailings to load it.

      If you are sending out hundreds of thousands of messages there are serious network/server issues. When we first started we killed out network as our firewall didn't have enough performance to handle a large amount of small connections.

      There is also the problem that 500,000 emails tends to be about 8 gig. This tends to be a very I/O bound operation and takes quite a while.

      How we handle things is we run postfix as our mail server. We first spool everything (without sending a single message) then let it go. We then throttle it so we're sending 40,000 or so an hour without killing our T1.

      There's also issues with web server load. It killed our client's webserver when it got that much extra traffic going there. There's also the problem about handling unsubscribes etc.

      And no, I don't spend all day sending spam :)

      Well that sounds like spam! :) If I may...to what purpose?

      This definitely does double the size of the emails...you've reminded me of something that Apache does...there is a negotiation compression with clients that have compression enable to cut down the costs of bandwidth. I wonder if there is a related thing with SMTP and POP/IMAP?

      Something to look into, anyway.

      Kickstart

Re: Re: HTML/Plain Text mail
by cat2014 (Monk) on Jan 05, 2002 at 23:57 UTC
    This is about how I do it, too. I have one suggestion-- make sure that the html message string has no newlines in it.

    I don't remember which ones (maybe hotmail??), but some mailreaders display the html of multipart messages with a really screwy layout if there are newlines in there. So, s/\n\t//g is your friend. (If you're getting the text of the mail from folks who write it up in M$ products, like Word, then you want to expand that regex to strip out more characters-- Word puts in funky ^M's and stuff that you'll want to remove as well.)

    -- cat