I'm using the following code to try and forward my mail from a pop account to my gmail using my ISP's SMTP server. Unfortunately, it never seems to work quite right. In the log file I get something like:
... Net::SMTP=GLOB(0x16e2b34)>>> right" Net::SMTP=GLOB(0x16e2b34)>>> >r</span><BR> Net::SMTP=GLOB(0x16e2b34)>>> </DIV></BODY></HTML> Net::SMTP=GLOB(0x16e2b34)>>> ------=_NextPart_000_0001_01C65387.769711 +20-- Net::SMTP=GLOB(0x16e2b34)>>> . Net::SMTP: Unexpected EOF on command channel at C:\perl\forwarder.pl l +ine 29
Any ideas?
#!perl use Net::POP3; use Net::SMTP; my $ServerName = "pop.server"; my $pop3 = Net::POP3->new($ServerName, Debug => 0); #redirect err open STDERR, ">>C:\\mail.log"; my $UserName = "username"; my $Password = "password"; my $msg_id; my $smtp = Net::SMTP->new('smtp.server', Debug => 1); die "Couldn't log on to server" unless $pop3; my $Num_Messages = $pop3->login($UserName, $Password); my $Messages = $pop3->list(); for $msg_id (keys(%$Messages)) { my $MsgContent = $pop3->get($msg_id); $smtp->mail('from@me.com'); $smtp->to('forward@address.com'); $smtp->data(); for (@$MsgContent) { $smtp->datasend($_); } $smtp->dataend(); my $delete_msg = $pop3->delete($msg_id); close OUT; } $smtp->quit(); $pop3->quit();

In reply to What's wrong with my forwarder? by Jobby

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.