CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
HTML in Sendmail

 



andy7t
User

Jan 29, 2004, 8:44 AM

Post #1 of 4 (604 views)
HTML in Sendmail Can't Post

Hello,

I need to send a HTML email using Sendmail.
How do i do this.

Everytime is send it, i just get the code in Outlook Express.

Andrew


davorg
Thaumaturge / Moderator

Jan 29, 2004, 10:38 AM

Post #2 of 4 (603 views)
Re: [andy7t] HTML in Sendmail [In reply to] Can't Post

1/ Are you sure you really want to do that? Many spam recognition systems automatically assume that pure-HTML email is spam. By sending HTML email you may be preventing many people from reading it.

2/ If you want to avoid this then you should send a properly formatted MIME message with an HTML version together with the same message in a text version.

3/ The best way to do this is to use MIME::Lite.

4/ If you want to avoid this advice, then the simplest solution to your problem is probably to include the correct Content-type header.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


andy7t
User

Jan 29, 2004, 12:22 PM

Post #3 of 4 (602 views)
Re: [davorg] HTML in Sendmail [In reply to] Can't Post

Hello.

Thanks for the advice.

I will look into MIME::Lite.

However, i do also have an opt-in system for either HTML or Text emails.

How do i set the content-type?

This is my code:

open (SENDMAIL, "| $sendmail -t") or print "Can't Open";
print SENDMAIL "Subject: $subject\n";
print SENDMAIL "From: $from\n";
print SENDMAIL "To: $to\n\n";
print SENDMAIL "Content-Type: text/html\n\n";



This doesn't work.

Thanks


davorg
Thaumaturge / Moderator

Jan 29, 2004, 12:44 PM

Post #4 of 4 (601 views)
Re: [andy7t] HTML in Sendmail [In reply to] Can't Post

It doesn't work because you aren't sending a content-type header. What looks like a content-header in your code is part of the email body. The headers are separated from the body by an blank line. The headers finish with the first "\n\n" that you print.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives