Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mime::Lite

1 view
Skip to first unread message

E. Preble

unread,
Nov 21, 1998, 3:00:00 AM11/21/98
to
I'm new to modules, and am trying to impliment a Mime::Lite call
for attaching a binary to an email.

Can someone show me an example of how a module call would look?
i.e. I'm getting all kinds of errors trying to get Mime::Lite to
actually send an email with an attachment, and I want to make sure
I have the syntaxes correct.

Thanks ahead.

E Preble


David Daniel

unread,
Nov 23, 1998, 3:00:00 AM11/23/98
to
"E. Preble" wrote:
>
> I'm new to modules, and am trying to impliment a Mime::Lite call
> for attaching a binary to an email.

I use this on an NT machine, and since Mime::Lite explicitly calls
sendmail, I have to save the message body as a string and then use
Net::SMTP to send it. Something like this (not a binary attachment, but
it sounds like your problem is the sending) ...

use File::Basename;
use MIME::Lite;
use Net::SMTP;

...

my $msg = new MIME::Lite
Subject =>"ECR Status Report",
Type =>'text/html',
Path =>$htmlfile,
Filename =>basename($htmlfile);

attach $msg
Type =>'text/plain',
Path =>$csvfile,
Filename =>basename($csvfile);

smtp($msg->as_string(), $smtphost, $sender, @recipient);

sub smtp {

my ($message, $mailhost, $sender, @recipient) = @_;

# Sends email to a list of recipients using Net::SMTP

my $smtp = Net::SMTP->new($mailhost);
$smtp->mail($sender);
$smtp->to(@recipient);
$smtp->data();
$smtp->datasend("From: $sender\n");
$smtp->datasend("To: " . join(', ', @recipient) . "\n");
$smtp->datasend($message);
$smtp->dataend();
$smtp->quit();
}

--
David Daniel

0 new messages