|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
When sending email through perl, what do you have to do to enable HTML tags in the email?
|
|
#2
|
|||
|
|||
|
It's quite simple if you look at this script.
############################################# #!/usr/local/bin/perl $email = 'webmaster@devshed.com'; $youremail = 'your@email.com'; open (MAIL,"|/var/qmail/bin/qmail-inject"); print MAIL "Subject: HTML Emailn"; print MAIL "From: DevShed.com <$email>n"; print MAIL "To: miguelgarcia <$youremail>n"; print MAIL "Content-type: text/htmlnn"; print MAIL "<html><body><p>n"; print MAIL "<blink>Hello</blink></p>n"; print MAIL "</body></html>n"; close (MAIL); print "Content-type: text/htmlnn"; print "DONEn"; ############################################ The whole idea is that you are sending the BODY of your email in HTML, so place it right b4 the body of the message. |
|
#3
|
|||
|
|||
|
I tried the code above and the "Content-type: text/html" shows in my email as part of the content.
I am using sendmail since I do not have qmail-inject installed on our server. Does sendmail not have the capability to send html formatted emails? |
|
#4
|
|||
|
|||
|
>>I am using sendmail since I do not have..
Simply change that line to: open (MAIL,"|/usr/sbin/sendmail -t"); >>the "Content-type: text/html" shows in my email as part of the content.. print MAIL "To: miguelgarcia <$youremail>n"; print MAIL "Content-type: text/htmlnn"; # make sure this line is in this position print MAIL "<html><body><p>n"; #if you are using M$ outlook, you might need to remove one newline as: print MAIL "Content-type: text/htmln"; |
|
#5
|
|||
|
|||
|
Yeah the problem was the extra "n" so now internet mail accounts and Microsoft email programs do recognize the html formatting.
I realized after sending the mail, thats the way it goes, that AOL and Lotus Notes did NOT recognize the html tags. Does anyone have any ideas for thoose browsers or maybe a more universal format???? Thanks for all help thus far. |
|
#6
|
|||
|
|||
|
>>that AOL and Lotus Notes did NOT recognize the html tags.
So your clients/members complain about that? Tell them go to http://www.aolsucks.com or block aol emails from registering. So AOL really can't read html email? Lotus Notes, I dun know about it. I suggest you not to send html emails if possible. Many people don't like to enable html email. |
|
#7
|
|||
|
|||
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by miguelgarcia:
When sending email through perl, what do you have to do to enable HTML tags in the email? [/quote] I send html mail as an attachment. Of course I use an established module for this: MIME::Lite to give you an idea how easy it is: attach $mail Type =>'text/html', Data =>$save_html; $save_html is the html version of the email I am sending. Go to CPAN and lookup the documenation for that module. I use it a lot. Peter ------------------ Exercise Your Brain,Read a Book |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > howto: HTML formatted email? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|