Re: HTML Emails
- From: Joe Smith <joe@xxxxxxxxx>
- Date: Sun, 21 Aug 2005 01:28:11 -0700
John smith wrote:
I am trying to use Sendmail to send an HTML email. apart from not wotking the folloing script returns and erro message of Premature end of script headers
#!/usr/bin/perl
use CGI;#::Carp qw(fatalsToBrowser);
my $to='example@xxxxxxx';
my $from= 'example@xxxxxxx';
my $subject='Using Sendmail';
open(MAIL, "|/path/sendmail -t"); print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n\n"; print MAIL "Content-type: text/html\n\n";
That's your problem. You need to output two different content-type headers, one to the browser, the other to sendmail. Use the "here-document" style instead of several print()s.
print header; # This goes to the browser print MAIL <<"HEADER"; # This goes to sendmail To: $to From: $from Subject: $subject Content-type: text/html
HEADER
print MAIL <<"MESSAGE"; # Rest of message
your message goes here
MESSAGE
close MAIL or warn "Problems in sending mail: $!";
print start_html('Thank you'),
h1('Your message has been sent'),
end_html; # This goes to browser.Better yet, use MIME::Lite::HTML and post to the comp.lang.perl.misc newsgroup instead of this one (comp.lang.perl). http://search.cpan.org/~alian/MIME-Lite-HTML-1.21/HTML.pm
-Joe .
- References:
- HTML Emails
- From: John smith
- HTML Emails
- Prev by Date: HTML Emails
- Next by Date: Newbie Question
- Previous by thread: HTML Emails
- Next by thread: Newbie Question
- Index(es):