Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: send mail with attachment using SMTP

by BlueLines (Hermit)
on Mar 09, 2001 at 14:51 UTC ( [id://63223]=note: print w/replies, xml ) Need Help??


in reply to send mail with attachment using SMTP

uh, you set $codepath to "cat $gifpath", which is not likely to be a filename on your machine. Try backticks around cat $gifpath, or just use $gifpath as the arg for MIME::Lite::Path?

BlueLines

Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

Replies are listed 'Best First'.
Re: Re: send mail with attachment using SMTP
by Ah CHU (Initiate) on Mar 09, 2001 at 15:04 UTC
    oh yes ... i have changed to and then without error ... thx ...
    ### Cat (Unix only): if (1) { my $path = "$gifpath"; $msg->attach(Subject => "Cat path to pipe, and read that", Path => $path,
    the program can run without error ... however ... i can't receive the mail ... maybe my program can't send actually after reading the docs in the module : Change how messages are sent
    ### Do something like this in your 'main': if ($I_DONT_HAVE_SENDMAIL) { MIME::Lite->send('smtp', "smtp.myisp.net", Timeout=>60); } ### Now this will do the right thing: $msg->send; ### will now use Net::SMTP as shown above
    my NT machine hasn't SENDMAIL ... how can i change the way of how i send ? here is my test mail written so far...
    #!/usr/bin/perl -w use strict; use MIME::Lite; use Getopt::Std; #------------------------------ # main #------------------------------ sub main { my %opts; ### Get options: getopts('', \%opts) or die "usage error\n"; my $gifpath = $ARGV[0] || die "missing path to GIF\n"; ### Create message: my $msg = MIME::Lite->new( To => 'ustchu@sinaman.com', Subject => 'GIF test', Type => 'multipart/mixed'); ### Read data: open IN, "<$gifpath" or die "open $gifpath: $!\n"; binmode IN; my @data; local $_ = ''; while (read(IN, $_, 1024)) { push @data, $_; } close IN; ### Direct path: if (1) { my $path = $gifpath; $msg->attach(Subject => "Read path directly", Path => $path, Type => 'image/gif'); } ### Cat (Unix only): if (1) { my $path = "$gifpath"; $msg->attach(Subject => "Cat path to pipe, and read that", Path => $path, Type => 'image/gif'); } ### Array: if (1) { $msg->attach(Subject => "Read data as array", Data => \@data, Type => 'image/gif'); } ### String: if (1) { $msg->attach(Subject => "Read data as string", Data => join('', @data), Type => 'image/gif'); } ### Output: # $msg->print(\*STDOUT); } exit(&main ? 0 : -1); 1; __END__

    Edit: 2001-03-09 by mirod: added <code> tags

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://63223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found