Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to send html email from perl

Reply
Thread Tools

how to send html email from perl

 
 
Eric Osman
Guest
Posts: n/a
 
      06-27-2003

I just had the same question, and found that the following works.

If you're using the "sendmail" package (see
http://ls6-www.cs.uni-dortmund.de/cg...%2fcpan%7c4120
)

Here's an example of sending an html message. NOTE: To actually use
this example, you will need to change the following things:

1) The first two lines might need to be swapped or otherwise modified
according to what your web server and perl require at the beginning of
perl scripts.
2) The "to" line needs to be edited to show who you're actually sending
the email to.
3) The "smtp" line needs to be changed to contain an outgoing mail
server that you are allowed to use.

ok here's the example:

#!perl
#!/usr/bin/perl
# Example of using sendmail to send html. Author: Eric Osman June 2003
use strict;
use CGI qw(:cgi);
use CGI::Carp qw(fatalsToBrowser);
use Mail::Sendmail;
my $msg = "";
$msg .= "here's some <b>boldface</b> to prove that html is being sent<br>";
$msg .= "a second line<br>";
my %mail = ( From => '',
To => '',
Subject => "some simple html",
Message => "$msg",
Smtp => 'smtp.cn.com',
'Content-type' => 'text/html; charset="iso-8859-1"'
);
sendmail(%mail) || die $Mail::Sendmail::error;
print "Content-type: text/html\n\n";
print "your html email has been sent";

Enjoy.

/Eric


> From: Mark A. Hershberger ()
> Subject: Re: Perl, HTML to Sendmail...
>
> View this article only
> Newsgroups: comp.lang.perl.misc
> Date: 1999/09/28
>
> [mailed and posted]
>
> "Myriad" <> writes:
>
>> Hello, I'm looking for info on how to recode my Perl script to send HTML
>> enabled mail via Sendmail. Can anyone help?

>
> (Strange, I had a user ask me the same question today. Perhaps you
> are one and the same.)
>
> Find the MIME-tools package on CPAN (or, if you need a URL:
> http://www.cpan.org/modules/by-module/MIME) and install it. In the
> tar package, look at examples/mimesend for an example of how to send
> html mail.
>
> Also, please give users the option to get plain text email instead of
> HTML mail. HTML mail can be annoying.
>
> Hope that helps,
>
> Mark.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
which email module - MIME::LITE, Email::Send, other? brewsterbear@googlemail.com Perl Misc 2 01-05-2007 09:45 AM
Cannot compose ,reply or send email on Sasktel email system pcbutts1 Computer Support 5 07-29-2005 06:13 AM
why cant i send email messages from this email Billie Jo Ames Computer Support 8 06-30-2005 12:24 PM
HowTo:? open email client to send email Peter ASP .Net 0 07-01-2003 04:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57