use warnings; use strict; use MIME::Lite; my $body; { #snarf the file into the variable $body local $/ = undef; open SCI_DUMP_OUT, "<$sci_dump_out" or die "could not open file $sci_dump_out: $! ; $body = ; close SCI_DUMP_OUT or warn "could not close file $sci_dump_out: $!"; } #you must define $to, $cc, $subject, $from, and $smtp_server my %msg = ( to => $to, cc => $cc, subject => $subject, body => $body, from => $from, server => $smtp_server); send_email(%msg); sub send_email { #send email via SMTP using MIME::Lite my %email = @_; my @must_have = qw(server from to subject body); foreach (@must_have) {die "send_email: must provide parameter: '$_'" if not defined $email{$_}}; MIME::Lite->send('smtp',$email{server},Timeout=>60); my $msg = MIME::Lite->new( From => $email{from}, To => $email{to}, Cc => $email{cc}, Subject => $email{subject}, Type => 'multipart/mixed' ); $msg->attach(Type => 'TEXT', Data => $email{body}, ); $msg->send; } #### use strict; use warnings; use Net::FTP; my ($host, $user, $pass) = qw(host.some.domain username password); my $ftp = Net::FTP->new($host) || die "Could not open connection to '$host'"; $ftp->login($user,$pass) or die "could not login: $!"; $ftp->cwd("test"); $ftp->get("that.file"); $ftp->quit();