#!/usr/bin/perl use warnings; use strict; use MIME::Lite; use Net::SMTP; my ($from, $to, $subject, $date, $sent_from); my $found = 0; my $to_string = "resume\@resume.example.com"; my $subject_string = "resume"; my $result; while(defined(my $line = )) { if (($result) = ($line =~ m/^From:\s+(.*?)\n/i)) { $from = $result; $found++; } elsif (($result) = ($line =~ m/^To:\s+(.*?)\n/i)) { $to = $result; $found++; } elsif (($result) = ($line =~ m/^Subject:\s+(.*?)\n/i)) { $subject = $result; $found++; } elsif (($result) = ($line =~ m/^Date:\s+(.*?)\n/i)) { $date = $result; } elsif (($result) = ($line =~ m/^Received:\s+from\s+(.*)/i)) { $sent_from = $result; } } # From, To, Subject are required by this script if ($found < 3) { print "**** CRITICAL MESSAGE HEADERS ARE MISSING ****"; exit 1; } elsif ($ARGV[2] ne $to_string) { print "**** EMAIL MUST BE ADDRESSED TO 'resume\@examplexamplee.com' ****"; exit 1; } elsif (not ($subject =~ m/resume/i)) { print "**** SUBJECT LINE MUST CONTAIN THE WORD 'RESUME' ****"; exit 1; } my $body=< "\"Adam\" ", To => $from, Subject => 'Requested: Adam\'s Resume', Type => 'multipart/mixed' ); #Body $msg->attach( Type => 'TEXT', Data => $body ); #Attachments $msg->attach( Type => 'text/plain', Path => '/home/adkap/www/resume/resume.txt', Filename => 'resume.txt', Disposition => 'attachment' ); $msg->attach( Type => 'application/pdf', Path => '/home/adkap/www/resume/resume.pdf', Filename => 'resume.pdf', Disposition => 'attachment' ); $msg->attach( Type => 'application/msword', Path => '/home/adkap/www/resume/resume.doc', Filename => 'resume.doc', Disposition => 'attachment' ); MIME::Lite->send('smtp', 'localhost', Timeout => 60); $msg->send(); #close OUT; exit 0;