neilwatson has asked for the wisdom of the Perl Monks concerning the following question:

Brothers,
I am attempting to write a script that will send and html newsletter for a client. Consider the following code:

#!/usr/bin/perl -w use strict; use warnings; use Mail::Sender; my $sender = new Mail::Sender {smtp => 'localhost'}; $sender->OpenMultipart({ from => 'marketing@mydomain.foo', to => 'marketlist@mydomain.foo', subject => 'we are so great!', type => 'multipart/related' }); $sender->Attach({ description => 'html body', ctype => 'text/html; charset=us-ascii', encoding => '7bit', disposition => 'NONE', file => 'mes.html' }); $sender->Attach({ description => 'vici gif', ctype => 'image/gif', encoding => 'base64', disposition => "inline; filename=\"VICI.gif\";\r\nContent-ID: <img +1>", file => 'VICI.gif' }); $sender->Close;

I've had limited success with this. Some email clients receive the html and image in the body others (Outlook) receive both as attachments. Is there a way I can ensure that the html and images will come in the message body?

Thanks,

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Sending HTML Mail
by gav^ (Curate) on May 03, 2002 at 20:00 UTC
    See MIME::Lite - For outging mail with attachments.

    You might have better luck putting the images on a webserver somewhere and referencing them in the HTML. It's a more polite way to do things.

    Also calling scrub on the MIME::Lite object seems to work better with some older clients.

    Hope this helps.

    gav^

Re: Sending HTML Mail
by Dog and Pony (Priest) on May 03, 2002 at 20:00 UTC
    I seem to recall something about using multipart/alternative as type instead of multipart/related, but I am not sure. It might be worth a shot? Either way, it is *probably* a header problem if different email clients present it differently.
    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
        Try nesting them. The multipart/alternative content type is meant more for saying "I can show you this type of content, or this type, you decide." You're doing it right with the multipart/related to combine images with an HTML content type.
        multipart/alternative multipart/related text/html image/gif whatever/else text/plain (a plain-text version)
        If that doesn't work, I might want to see the actual output of your script, if you can reduce it to something small-ish.