http://www.perlmonks.org?node_id=20685

csorensen has asked for the wisdom of the Perl Monks concerning the following question:

I think that I've narrowed the problematic code down to these snippets
$path = ''; $new_message = MIME::Lite->new( From =>'info@constellar.com', To =>"$receiver", Subject =>'Whitepaper request', Type =>'multipart/mixed' ); $new_message->attach(Type =>'BINARY', Path =>"$path", Filename =>"$file" ); $new_message->send;
The script runs fine when I comment out the $new_message->attach block ..
either the $path or one of the Type's is wrong ... I think .. any ideas ?

Replies are listed 'Best First'.
(jcwren) Re: trying to attach with MIME::Lite
by jcwren (Prior) on Jul 01, 2000 at 03:38 UTC
    I think possibly you're misinterpeting what the path and file parameters are. path is the path/name of the file on the system you're sending from. file is the name that you want the receiver to see it as.

    In the example below (your code, with the addition of "use strict;" and -w), the name of the Perl executable is test.pl. When I run this code, I receive the e-mail with the filename of the attachment as newname.pl. Try this code on your system (changing the names of the receiver, of course), and see if it works for you.

    (Basically, the program (test.pl) sends itself to the receiver (receiver@linux.private.com), encoded as a binary attachment (named newname.pl), from sender@linux.private.com.)
    #!/usr/local/bin/perl -w use strict; use MIME::Lite; { my $path = 'test.pl'; my $file = 'newname.pl'; my $receiver = 'receiver@linux.private.com'; my $new_message = MIME::Lite->new( From =>'sender@linux.private.com', To =>"$receiver", Subject =>'Whitepaper request', Type =>'multipart/mixed'); $new_message->attach( Type =>'BINARY', Path =>"$path", Filename =>"$file"); $new_message->send; }
    --Chris
Re: trying to attach with MIME::Lite
by csorensen (Beadle) on Jul 01, 2000 at 07:26 UTC
    ack - you're right .. thanks .. I thought the path param meant literal path