in reply to Re: send mail with attachment using SMTP
in thread send mail with attachment using SMTP

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