Sending HTML (MIME) email with Net::SMTP ?

S

still just me

I'm trying to send HTML email (email with a MIME header) using
Net::SMTP in my code. (Hopefully eventually sending multipart
text/plain and text/HTML).

I've been sending plain text email with the code below in quite a few
programs... works fine. But, I am having trouble figuring out how to
send MIME email. I thought that if the headers appeared first in the
body section that it would work but that was a flop - it all shows up
as the body of the message.

I could use some help, or pointers. I could not find anything specific
in perldoc on this... perhaps I need to use another module to generate
MIME headers? I'd like to avoid changing modules if I can since
Net::SMTP seems to work well otherwise.

Thanks,
 
S

still just me

Forgot the snippet. Here's the code I normally use:

my $smtp = Net::SMTP->new('localhost');
die "Could not open connection: $!" if (! defined $smtp);

$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("$body\n");
$smtp->dataend();
$smtp->quit;
 
J

John Bokma

still just me said:
I could use some help, or pointers. I could not find anything specific
in perldoc on this... perhaps I need to use another module to generate
MIME headers? I'd like to avoid changing modules if I can since
Net::SMTP seems to work well otherwise.

Check out MIME::Lite
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top