E
Eric Osman
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/c...|CPAN|wait|/services/www-db/WAIT/DB/cpan|4120
)
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 qwcgi);
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 => '(e-mail address removed)',
To => '(e-mail address removed)',
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
If you're using the "sendmail" package (see
http://ls6-www.cs.uni-dortmund.de/c...|CPAN|wait|/services/www-db/WAIT/DB/cpan|4120
)
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 qwcgi);
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 => '(e-mail address removed)',
To => '(e-mail address removed)',
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 ([email protected])
Subject: Re: Perl, HTML to Sendmail...
View this article only
Newsgroups: comp.lang.perl.misc
Date: 1999/09/28
[mailed and posted]
Myriad said: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.