cc has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use warnings; use MIME::Lite; use Net::SMTP; my $mail_host = "192.168.1.1"; my $linux = "root\@mydomain.net"; my $recipient = "recipient\@mydomain.net"; my $file = "/srv/ftp/lc/*.DOC"; my $subject = "invoice"; # send a mail with the attachment my $msg = MIME::Lite->new( From => "$linux" , To => "$recipient" , Subject => "$subject", Type => 'multipart/mixed', ); $msg->attach(Type =>'TEXT', Data =>"invoice" ); $msg->attach(Type =>'application/doc', Path =>"$file", Filename =>'?', Disposition => 'attachment' ); # ----- Tell MIME::Lite to use Net::SMTP instead of sendmail MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send; # create a backup subfolder after mail was sent my @dt = localtime; my $subfolder_name = ((((1900 + $dt[5]) * 100 + 1 + $dt[4]) * 100 + $d +t[3]) * 100 + $dt[2]) * 100 + $dt[1]; mkdir "/srv/ftp/lc/save/$subfolder_name" or die "$subfolder_name: $!"; # move the file to the backup subfolder system("mv $file /srv/ftp/lc/save/$subfolder_name"); exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: look for a file and send as a mail attachment by mail
by roboticus (Chancellor) on May 31, 2006 at 02:21 UTC | |
by lukeyboy1 (Beadle) on May 31, 2006 at 09:04 UTC |