email html format

How can I send the HTML format in the email?
jpchenAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
guadalupeConnect With a Mentor Commented:
I had this problem recently and my solution although containing a few extra steps was the best I came up with.

First write the email in a HTML able mail prog such as Outlook Express.  Send it to another HTML able mail prog.

Then use the prog to view the source of the message (Not the message but the real source with mail headers and all)

In Outlook the steps are:
File->Properties->Details->Message Source

Copy the source and paste it into the code below:

#!/usr/local/bin/perl
#
# Send message with SMTP.
#
use Net::SMTP;

#PLACE HOST WITH SMTP SERVER HERE
$hostname = "HOST NAME WITH SMTP";

#PLACE ADDRESS TO SEND TO HERE REMEMBER TO USE SINGLE QUOTES BECAUSE OF THE @
$address ='ADRESS';

#PLACE FROM ADDRESS HERE REMEMBER TO USE SINGLE QUOTES BECAUSE OF THE @
$from_address = 'FROM';
#
# Connect to SMTP server.
#
$mailserv = new Net::SMTP($hostname, Debug => 1,);
#
# Format message.
#
$data = <<END;

#Source as copied from mail prog

END
#
# Send the message.
#
$mailserv->mail( $from_address );
$mailserv->to( $address );
$mailserv->data( $data );
#
# Close connection.
$mailserv->quit();

# smtp.pl
0
 
KennyIT Application ExecutiveCommented:
Use MS Outlook and choose "always send to this recipient in rich text format".

I think Outlook express also can do it.
0
 
maxkirCommented:

This function works for most UNIX systems:


############################################################
# Sending mail function
# Parameters:
#  send_mail( recipient, mail from, subject, message content);
############################################################
sub send_mail()
{
   local($to, $from, $subj, $html_content) = @_;

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

   print MAIL "To: $to\n";
   print MAIL "From: $from\n";
   print MAIL "Content-type: text/html\n";
   print MAIL "Subject: $subj\n\n";

   print MAIL "$html_content";

   close (MAIL);
}
0
 
guadalupeCommented:
To finish, I this necessary because, as you will notice, the source in the end is not just simple html  Links, Sources, Accents and many other things have their own little oddities like the '3D' for links.  I have yet to find a modual that does the coding for you and sendmail doesn't seem to do it either so... here's the long answer.  Just reject it if you find something simpler that works (and let me know for the next time).
0
All Courses

From novice to tech pro — start learning today.