I have a sample script to check and autorespond to email and I would like to modify it to work on a windows platform for a pop3 account. I am really not sure how to pull this off but would really like to get it working, I figure I will need to connect to the pop3 and then somehow switch to inbox then parse the messages, most of this logic should work but I am stuck on figuring out how to connect to the pop3 and also switching to the inbox.
#!/usr/local/bin/perl5 use SMTPwrap; my %mailheader; my $mailbotaddress = "support\@mlxchange.com"; close(STDERR); close(STDOUT); my %commandlist = ( 'send' => 'send_file', 'list' => 'send_list', 'help' => 'send_help', ); chdir("/users/martinb/sub/mail"); my $state=1; while(<STDIN>) { chomp; if (length($_) eq 0) { $state=0; next; } if ($state) { if ( m/^From\s/) { next; } elsif ( m/(^[\w\-\.]+):\s*(.*\S)\s*$/) { $keyword = $1; $value = $2; $mailheader{$keyword} = $value; } else { $mailheader{$keyword} .= "\n" . $_; } } else { my ($command, @opts) = split; my $to = clean_address(return_address(\%mailheader)); next if /^\s*$/; unless ($commandlist{lc($command)}) { send_error($to,"Unknown command, $command.\n" . "Rest of Message ignored.\n",1); } my $function = $commandlist{lc($command)}; &$function($to,$opts[0]); } } sub send_error { my ($to,$error,$fatal) = @_; mail_a_message("Mailbot Error",$to,$mailbotaddress,$error); exit(1) if $fatal; } sub send_list { my $to = shift; send_file($to,"list"); } sub send_help { my $to = shift; send_file($to,"help"); } sub send_file { my ($to,$filename) = @_; $filename =~ s#^.*/##; $filename =~ s/[^\w\.\-]//g; send_error($to,"Cannot open $filename",0) unless (open(D, "<$filename")); my $message = "Attached below is the file $filename\n"; $message .= "------------------------------------\n\n"; $mailheader{subject} = "" unless $mailheader{subject}; { local $/; $message .= <D>; } close(D); send_error($to,"Error: $SMTPwrap::error",0) unless(mail_a_message("Mailbot Reply to job, " . "$mailheader{subject}", $to,$mailbotaddress,$message)); }

In reply to modifying for windoze by grashoper

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.