Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Send HTML mail to Outlook

by cosmicsoup (Beadle)
on Apr 06, 2004 at 16:44 UTC ( [id://343008]=perlquestion: print w/replies, xml ) Need Help??

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

Monks,

I'm stumped! I am generating some HTML with perl to send an email report once a week. The output looks good on AOL (believe it or not) but shows up as source code on Outlook. I've tried inserting Content-type's and header's (even CSS) to no avail. Keeps showing as code. Does anyone have any suggestions? I've seen the posts on MIME::Lite, but I haven't been able to get that successfully running on my host.

Many Thanks!
Louis

Replies are listed 'Best First'.
Re: Send HTML mail to Outlook
by esskar (Deacon) on Apr 06, 2004 at 18:16 UTC
    are you sure that you send a right formatted HTML mail...
    have you set the MIME-Version? here is an sample of a well formed MIME HTML mail:
    Subject: Some Subject Date: Wed, 17 Dec 2003 12:26:50 +0100 Message-ID: <E1E811923F2F054DB62E330FE5B3720544D7A7@sub.host.dom> From: "Body, Some" <some.body@host.dom> To: "Body, Any" <any.body@host.dom> MIME-Version: 1.0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <TITLE></TITLE> </HEAD> <BODY> <P><FONT SIZE=3D2 FACE=3D"Arial">This is a Test.</FONT> </P> <P><FONT SIZE=3D2 FACE=3D"Arial">Bye,</FONT> <BR><FONT SIZE=3D2 FACE=3D"Arial">Some Body</FONT> </P> </BODY> </HTML>
    Have fun! :)
      I have entered the exact same META tags within the <head> tags. On Outlook it still displays it as code. On AOL it displays this in the html email:
      <html><head><META http-equiv=Content-Type content="text/html; charset= +us-ascii"></head>
      By the way, I just got MIME::Lite::HTML installed, although it doesn't seem to send my HTML to the email address. I have a perl script called weekly.pl that reads in data from a flat file and puts it into a file in HTML format. I then use the unix mail command to send the file to a list of recipients. When you attach a file via MIME, does it display it in an email or do you have to download it?

      Any and all suggestions are appreciated.

      thanks,
      Louis
        You can't expect Outlook to understand that this file is in html by looking for the mime type specified inside a <META> tag: the reason is that text/html should be specified on the envelope and not inside the content.
        What you should do is send the correct mime header before sending the content:
        Content-type: text/html This is slurped as <b>html</b> by my mail client!
        should give you the idea!
        Ant9000
Re: Send HTML mail to Outlook
by muba (Priest) on Apr 06, 2004 at 16:49 UTC
    As far as I know, it's "Content-Type", not "Content-type" (mind the capital T just after the hyphen).
    I once learned "be strict in what you send, be flexible in what you receive".
    Most programs follow this rule quite well and don't bother about capitals. Maybe Outlook does?
      I have tried every conceivable way to enter content-type, I get the same results every time.

      Louis
Re: Send HTML mail to Outlook
by gmpassos (Priest) on Apr 07, 2004 at 04:47 UTC
    Just use Mail::SendEasy. It just works very well with HTML messagens and attachments. Also is easy to install, since it doesn't have dependencies.

    Here's an example of use:

    use Mail::SendEasy ; my $mail = new Mail::SendEasy( smtp => 'localhost' , user => 'foo' , pass => 123 , ) ; my $status = $mail->send( from => 'sender@foo.com' , to => 'recp@domain.foo' , subject => "MAIL Test" , msg => "The Plain Msg..." , html => "<b>The HTML Msg...</b>" , ) ; if (!$status) { print $mail->error ;}
    In the example above it's sending a multipart message, with a text and a HTML version at the same time. Soo, you don't need to care about the MIME message. ;-P

    Good luck. ;-P

    Graciliano M. P.
    "Creativity is the expression of the liberty".

Re: Send HTML mail to Outlook
by atcroft (Abbot) on Apr 06, 2004 at 17:57 UTC

    My guess is that MUBA hit it on the head. However, you may also want to take a look at Mail::Sendmail. Since you didn't mention which module (if any) you were using to send, it may prove helpful in more than one way. Specifically, you'll probably want to take a look at the FAQ that it links to, which I believe includes an example of sending HTML email, among other things, although if you use that module one of the parameters you can give it when the object is created handles the content type representation to the MTA, iirc. HTH...

Re: Send HTML mail to Outlook
by neilwatson (Priest) on Apr 07, 2004 at 15:15 UTC
    I use Mail::Sender to do my bidding:
    sub mailout { $sender = new Mail::Sender; $sender->Open({ smtp => $smtp, skip_bad_recipients => 'true', from => "foo\@bar.com", fake_from => $from, to => "subscribers\@bar.com", bcc => $to, encoding => "quoted-printable", subject => $subject, ctype => $htype, headers => "Errors-To: errors@bar.com", }) or usage(), warn "Sender error: $sender, $Mail::Sender::Error!\n"; # body of email. USE Send only for plain/text messages if ($htype eq "text"){ $sender->Send(@body)or usage(), warn "Sender error: $sender, $Mail::Sender::Error!\n"; }else{ $sender->SendEnc(@body) or usage(), warn "Sender error: $sender, $Mail::Sender::Error!\n"; } # send email $sender->Close or usage(), warn "Sender error: $sender, $Mail::Sender::Error!\n"; }

    Neil Watson
    watson-wilson.ca

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://343008]
Approved by Thelonius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-18 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found