For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2005 > HTML Emails









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author HTML Emails
John smith

2005-07-30, 9:59 pm

I need to set up a process to send both html and text eamils from within
perl. I can make things work to send the text based email but even a simple
html email is always sent as text. I have not even gotten to the stage of
trying both in the same email
Nearest I can figure the following should send a simple html email

#!/usr/bin/perl
print "Content-type: text/html\n\n";

$title='mail test';
$to='recipient\@address.net';
$from= 'sender\@address.net';
$subject='Using Sendmail';

open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message\n";

close(MAIL);

print "<html><head><title>$title</title></head>\n<body>\n\n";

## START HTML content
print "<h1>$title</h1>\n";
print "<p>A message has been sent from $from to $to";
## END HTML CONTENT
print "\n\n</body></html>";




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com