in reply to Re: Still New to Perl / html email
in thread Still New to Perl / html email

Im still new to Perl too but I know that to send email formatted in HTML is quite simple. I am not familiar with the module stated but I would like to go lower level than that. First, its all about the MUA (mail user agent or email client) and how it will interpret your email message. There of course are standards out there that make your MUA do what you want it to do. Thus, there are extension headers you can place in your emails that the MUA interprets. If you want to set your message priority you do that using the X-Priority header. If you want to do HTML, you set the Mime-version and your Content-type. There are many other things you can set that your MUA will interpret and others that it will ignore but that can be seen for informational purposes. Here are a few:
X-Mailer: MSN Explorer 6.00.0010.0912 X-OriginalArrivalTime: 23 Mar 2001 23:59:19.0685 (UTC) FILETIME=[4675A +B50:01C0B3F5] X-UIDL: 281293976 <-- set by the POP server
I like to test things via command line before doing them in a script though. So, what I did to test this out was I actually sent a message out via command line.
[ notjamesnjkwan ~ ] $ cat << msg | sendmail jconner@fake_domain.com > Mime-Version: 1.1 > Content-type: text/html > Subject: This is a test for html > <font color=blue>Line in blue</font><br> > <font color=red>Line in red</font> > . > msg
With sendmail you can basicly write some of your own headers which is what I did. After the headers were properly written for the MUA to interpret the HTML, I simply write the html. Thats it. In perl it should be the same way:
open(PIPE,"| /usr/lib/sendmail $RCPT"); print PIPE "Mime-Version: 1.1\r\nContent-type: text/html\r\n"; print PIPE "Subject: $SUBJECT\r\n"; print PIPE "message here with HTML embedded\r\n.\r\n"; close(PIPE);
I haven't actually tried the \r\n's in a single line yet but I see no reason why they shouldn't work :)

- Jim