Re: sending a file attachment using Net::SMTP
Brian Strand (bstrand@carclub.com)
Mon, 08 Feb 1999 15:31:25 -0800
You might want to check out MIME::Entity and company, specifically, the
build, attach, print, and stringify methods.
For example (from MIME::Entity documentation):
my $msg = MIME::Entity->build(
From => 'me@myhost.com',
To => 'you@yourhost.com',
Subject => "Hello, nurse!",
Data => [
'body text line 1',
'body text line 2',
'body text line 3'
]
);
$msg->attach(
Path => $my_file_to_attach,
Type => $my_files_mime_type,
Encoding => '-SUGGEST'
);
# set up SMTP recipient, sender here
$smtp->datasend($msg->stringify);
# or possibly $msg->print $smtp (I haven't tried this)
"SalomeH@tend.net" wrote:
>
> I am trying to send an email message that has some text and a file
> attachment. However, I can't figure out how to send the file as an
> attachment and not as the body of the message. Can someone help?
>
> ..
> ..
> ..
> ..
> $smtp->datasend("Subject: info from me\n");
> $smtp->datasend("To: salomeh\@tend.net\n");
> $smtp->datasend("From: salomeh\@tend.net\n");
> $smtp->datasend("\n");
> $smtp->datasend("simple test");
> #WANT TO SEND AN FILE ATTACHMENT NOW
> ..
> ..
> ..
> ..
>
> Thanks in adavance for your help.
>
> -Salome Harrison