Ok. I'm starting over and going to explain this slowly. First, I can 
successfully telnet into
  our IMail server via IMAP port 143 and login and logout fine. However, when I 
attempt to use
  ActiveState Perl v5.8.4 and the Perl module IO::Socket the login fails. The 
connection itself
  does succeed without error. I have listed below the secion of code again with 
the values hard
  coded. I have marked up the code below to show what the responses from IMail 
are at each step.
  I have also commented everything to include as much detail in an attempt to 
explain what goes
  on with the script.

  # 
------------------------------------------------------------------------------------------
  # This section is what establishes the connection to IMail via IMAP using 
Perl.
  
  # This creates a new IMAP connection to 63.110.140.31 using port 143 (IMAP). 
If the connection
  # is not successfull, the script will at this point die.
  
  $REM_IMAP = new IO::Socket::INET( PeerAddr => '63.110.140.31',
                                    PeerPort => 143
                                  ) || die "Can't connect to remote server via 
IMAP\n";

  # This will force the $REM_IMAP to flush after every print.
  
  $REM_IMAP->autoflush(1);
  
  # Now, we loop through the responses from IMail until we get the final 
response.
  
  do {
    $IMAPResponse = <$REM_IMAP>;
    print "$IMAPResponse\n"; # -----> This is here for debugging purposes.
  } until($IMAPResponse =~ /^\* /);
  
  #####  At this point, IMail has given the response "* OK IMAP4 Server (IMail 
8.15)" and
  #####  this is the ONLY response that is received.
    

  # 
------------------------------------------------------------------------------------------
  # This section is what performs the login to an e-mail account via IMAP using 
Perl. So, at
  # this point, the actual socket connection to IMail has succeeded 100% 
without error.

  # We now want to send to the socket connection the IMAP command to login. The 
'\n' (newline)
  # is needed at the end to signify the end of the input stream. On Windows, 
'\n' is translated
  # to <CRLF>.
  
  print $REM_IMAP "x LOGIN [EMAIL PROTECTED] password\n";

  # Again, we loop through the responses from IMail until we get the final 
response that begins
  # with 'x'. That is what we used in the line to login. Any character sequence 
can be used. It
  # is what assigns a unique value to the particular IMAP command issued. IMail 
should respond
  # to us each step of its way with responses starting with this value.

  do {
    $IMAPResponse = <$REM_IMAP>;
    print "$IMAPResponse\n"; # -----> This is here for debugging purposes.
  } until($IMAPResponse =~ /^x /);
  die "Can't login to remote IMAP: $IMAPResponse\n" unless($IMAPResponse =~ /^x 
OK/);
  
  #####  At this point, IMail has given the response "x BAD LOGIN Invalid 
Syntax" and
  #####  this is, again, the ONLY response that is received. With the response 
not matching
  #####  what we are looking for, the script dies because we have NOT 
successfully logged into
  #####  the e-mail account.

  # 
------------------------------------------------------------------------------------------

  I have also started up Ethereal to sniff the line BOTH on the telnet session 
as well as the
  Perl script session. BOTH do not look any differant than the other. I have 
also, again, done
  the same to two other MTA's we run here and they BOTH have no issues with the 
login sequence.
  
-----

Duane Hill
Sr E-Mail Administrator
http://www.yournetplus.com


To Unsubscribe: http://www.ipswitch.com/support/mailing-lists.html
List Archive: http://www.mail-archive.com/imail_forum%40list.ipswitch.com/
Knowledge Base/FAQ: http://www.ipswitch.com/support/IMail/

Reply via email to