Thanks for your help. I run this out of the crontab.
use Net::POP3; use Net::SMTP; #use warnings; use MIME::Base64 qw( encode_base64 ); $pophost = "YOUR MAIL SERVER"; $username = "EMAIL LOGIN NAME"; $password = "SUPER SAFE PASSWORD"; $pop = Net::POP3->new($pophost); $pop = Net::POP3->new($pophost, Timeout => 60); $pop = Net::POP3->new($pophost, SSL => 0, Timeout => 60); open(FH,">", "all_my_mail.txt") or die "$!"; if ($pop->login($username, $password) > 0) { my $msgnums = $pop->list; # hashref of msgnum => size foreach my $msgnum (keys %$msgnums) { my $msg = $pop->get($msgnum); print FH @$msg; $pop->delete($msgnum); #Uncomment to delete messages } } close FH; $pop->quit; #this sub is to match machine numbers to operation codes sub machconv { my ($machin) = @_; if ($machin == 500) { $sendback ="BOX"; } if ($machin == 1 || $machin == 2 || $machin == 3 ) { $sendback ="FM"; } if ($machin == 20 || $machin == 50 || $machin == 51 || $machin + == 59 || $machin == 67 ) { $sendback ="MAZ-2ND"; } if ($machin == 24 || $machin == 30 ) { $sendback ="RD"; } if ($machin == 29 || $machin == 72 ) { $sendback ="GD"; } if ($machin == 89 || $machin == 90 || $machin == 12 || $machin + == 13) { $sendback ="MAZ-COMP"; } if ($machin == 78 || $machin == 7 || $machin == 95) { $sendback ="MAZ-1ST"; } if ($machin == 37 || $machin == 38 || $machin == 36) { $sendback ="ROUGH-MILL"; } if ($machin == "PROG-01" ) { $sendback ="RAIL-PROG"; } if ($machin == "PRO" || $machin == 502) { $sendback ="MAZ-PROG"; } if ($machin == 44 || $machin == 53 || $machin == 54 || $machin + == 79 || $machin == 4) { $sendback ="SG"; } if ($machin == 45 || $machin == 63 || $machin == 5) { $sendback ="SAW"; } if ($machin == 55 || $machin eq "INSP-01") { $sendback ="INSPECT"; } if ($machin == 999 ) { $sendback ="OVERHEAD"; } if ($machin == 60 || $machin == 71 || $machin == 88 || $machin + == 35 || $machin == 39 || $machin == 10) { $sendback ="BG"; } if ($machin == 68 || $machin == 69 || $machin == 70 ||$machin= +=64) { $sendback ="TD"; } if ($machin == 77 || $machin == 99 || $machin == 97) { $sendback ="HAMMI"; } if ($machin eq "ASSLY-01" ) { $sendback ="ASSEMBLY"; } if ($machin eq "DEBURR-01" ) { $sendback ="DEBURR"; } if ($machin eq "ENG-01" || $machin eq "ENG-02" || $machin eq " +ENG-03" || $machin eq "ENG-04" || $machin eq "ENG-05" || $machin eq " +ENG") { $sendback ="PROCESSING"; } return $sendback; } #sub main....LOL open(FH, "all_my_mail.txt") or die "$!"; while (<FH>) { if(/^From:/){ #THis pulls out from off the message @Fld = split(/:/, $_); chomp; @front = split(/</,$Fld[1]); $address = $front[1]; $address =~ s/>//; } if(/^Subject:/){ #THis pulls out subject off the mes +sage @Fld = split(/:/, $_); chomp; push @job_out, $Fld[2]; if ($Fld[1] == "JOB") { job_print($Fld[2],$address);} } } #This pulls the jobs out and sends the e-mail (job number base) sub job_print { my ($jobin,$address) = @_; $pass1 = $jobin; $pass1 =~ s/\r|\n//g; $local_file =sprintf("%s.html",$pass1); open(OUTFILE,">",$local_file); $build_rtps = sprintf ("/usr/local/bin/dbfdump --fields order,oper,wor +k_cntr,complete,run,startdate /sambashares/sdrive/data/rtps.dbf |/us +r/bin/strings |/bin/grep %s |", $jobin); $pass1 = sprintf ("/usr/local/bin/dbfdump --fields order,oper,complete +,machine,date_in /sambashares/sdrive/data/tcard.dbf |/usr/bin/string +s |/bin/grep %s ", $jobin); $pass1 =~ s/\r|\n//g; $build_tcard = sprintf("%s |/usr/bin/sort -n -t: -k2,3 |",$pass1); print OUTFILE "ROUTING\n"; print OUTFILE "This is a static table built at time of last schedule t +his can be out of sync with the clock transactions.\n"; printf OUTFILE "<HTML>\n"; printf OUTFILE "<TABLE border=\"2\" colspan=\"1\" "; printf OUTFILE "rowspan=\"1\" cellspacing=\"1\""; printf OUTFILE " cellpadding=\"2\" width=\"100%%\" "; printf OUTFILE " bordercolor=\"#000080\" bgcolor=\"#FFFFFF\">\n"; printf OUTFILE "<TR>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>JOBNO</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>LINE NUMBER </BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>WORK CENTER</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>COMPLETE (Y/N)</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>TIME LEFT OPERATION</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>EXPECTED START DATE</BOLD>\n"; printf OUTFILE "</TH></TR>\n"; open(RTPS_PIPE, $build_rtps); while (<RTPS_PIPE>) { chomp; @Fld = split (/:/,$_,9999); if ($Fld[3] eq "Y") { # printf OUTFILE "%s \t %s \t %s \t %s\n", $Fld[0],$Fld[1],$Fld +[2],$Fld[3]; printf OUTFILE "<TR>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[0]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[1]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[2]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[3]; printf OUTFILE "</TH></TR>\n"; } else { #printf OUTFILE "%s \t %s \t %s \t %s\t %s\t %s \n", $Fld[0],$ +Fld[1],$Fld[2],$Fld[3],$Fld[4],$Fld[5]; printf OUTFILE "<TR>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[0]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[1]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[2]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[3]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[4]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[5]; printf OUTFILE "</TH></TR>\n"; } } close RTPS_PIPE; printf OUTFILE "</TABLE>\n"; print OUTFILE "TCARD TRANS \n"; print OUTFILE "All transactions are within the last 7 days. These are +live transactions that may not have updated the above routing yet.\n" +; printf OUTFILE "<TABLE border=\"2\" colspan=\"1\" "; printf OUTFILE "rowspan=\"1\" cellspacing=\"1\""; printf OUTFILE " cellpadding=\"2\" width=\"100%%\" "; printf OUTFILE " bordercolor=\"#000080\" bgcolor=\"#FFFFFF\">\n"; printf OUTFILE "<TR>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>JOBNO</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>LINE NUMBER </BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>WORK CENTER</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>COMPLETE (Y/N)</BOLD>\n"; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\n"; printf OUTFILE "<BOLD>LAST TRANS DATE</BOLD>\n"; printf OUTFILE "</TH></TR>\n"; #print $build_tcard; #print "\n"; open(RTPS_PIPE, $build_tcard); while (<RTPS_PIPE>) { chomp; @Fld = split (/:/,$_,9999); $wcentr = machconv($Fld[3]); if ($Fld[2] == '1') { $complete_out = "Y"; } else { $complete_ +out = "N"; } # printf OUTFILE "%s \t %s \t %s \t %s \t %s \n", $Fld[0],$Fld[ +1],$wcentr,$complete_out,$Fld[4]; printf OUTFILE "<TR>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[0]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[1]; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$wcentr; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$complete_out; printf OUTFILE "</TH>\n"; printf OUTFILE "<TH Width=\"14%%\" Align=\"center\" >\ +n"; printf OUTFILE "<BOLD>%s</BOLD>\n",$Fld[4]; printf OUTFILE "</TH></TR>\n"; } close RTPS_PIPE; printf OUTFILE "</TABLE>\n"; close OUTFILE; my $from = 'A FRIENDLY EMAIL FROM ADDRESS'; my $pass1 = sprintf("%s",$address); $pass1 =~ s/\r|\n//g; $to = sprintf("%s",$pass1); $to =~ s/\r|\n//g; my $attachBinaryFile= 'test.jpg'; my $attachTextFile = $local_file; my $boundary = 'frontier'; open(DAT, $attachTextFile) || die("Could not open text file!"); my @textFile = <DAT>; close(DAT); my $smtp = Net::SMTP->new('YOUR SMTP SERVER', Timeout => 60) || die("C +ould not create SMTP object."); #print "Sending mail\n"; $smtp->mail($from); $smtp->recipient($to, { SkipBad => 1 }); $smtp->data(); $smtp->datasend("To: $to\n"); $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: Job $local_file\n"); $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-type: multipart/mixed;\n\tboundary=\"$boundar +y\"\n"); $smtp->datasend("\n"); $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-type: text/plain\n"); $smtp->datasend("Content-Disposition: quoted-printable\n"); $smtp->datasend("\nToday\'s files are attached:\n"); $smtp->datasend("\nHave a nice day! :)\n"); $smtp->datasend("--$boundary\n"); $smtp->datasend("Content-Type: application/text; name=\"$attachTextFil +e\"\n"); $smtp->datasend("Content-Disposition: attachment; filename=\"$attachTe +xtFile\"\n"); $smtp->datasend("\n"); $smtp->datasend("@textFile\n"); $smtp->datasend("--$boundary\n"); #$smtp->datasend("Content-Type: image/jpeg; name=\"$attachBinaryFile\" +\n"); #$smtp->datasend("Content-Transfer-Encoding: base64\n"); #$smtp->datasend("Content-Disposition: attachment; filename=\"$attachB +inaryFile\"\n"); #$smtp->datasend("\n"); #my $buf; #open(DAT, "../uploads/$attachBinaryFile") || die("Could not open bina +ry file!"); ## binmode(DAT); # local $/=undef; # while (read(DAT, my $picture, 4096)) { # $buf = &encode_base64( $picture ); # $smtp->datasend($buf); # } #close(DAT); #$smtp->datasend("\n"); #$smtp->datasend("--$boundary\n"); #$smtp->dataend(); $smtp->quit; #print "Mail sent\n"; my @files = <*.html>; if (@files) { unlink @files or warn "Problem unlinking @files: $!"; } else { warn "No files to unlink!\n"; } }

Replies are listed 'Best First'.
Re: A Thanks sample POP3 Autoresponder
by LanX (Saint) on Feb 12, 2016 at 14:45 UTC
    do you have a question?

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

    update

    This thread originally appeared in SOPW.

      No just giving back for all the help from this sight

        You are using the wrong equality operator for strings here

        if ($machin == "PROG-01" )
        if ($machin == "PRO" || $machin == 502) 
        
        poj