Home > Archive > PERL Miscellaneous > May 2005 > Mail::IMAPClient via SSL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Mail::IMAPClient via SSL
|
|
| Greg G 2005-05-25, 8:56 pm |
|
I'm trying to get Mail::IMAPClient to work via SSL. I'm running into a
problem. Here's the output:
# ./imap_test.pl
SSL OK? 1
SSL says: * OK mailtest sendmail Server IMAP4rev1
(2.1.5/smserver-2-1-5-build-1174)
Using Mail::IMAPClient version 2.2.9 and perl version 5.8.6 (5.008006)
'0' '' |1|
Set State : 1
Sending literal string in two parts: 1 Login "ggtest103z@mydomain.net" {6}
then: abcdef
Sending: 1 Login "XXXXXX" {6}
Sent 38 bytes
Can't call method "can_read" on an undefined value at
/usr/local/lib/perl5/site_perl/5.8.6/Mail/IMAPClient.pm line 1583.
#
#
then: abcdef
Sending: 1 Login "XXXXXX" {6}
Sent 38 bytes
Can't call method "can_read" on an undefined value at
/usr/local/lib/perl5/site_perl/5.8.6/Mail/IMAPClient.pm line 1583.
#
---------------------------
Here's the code:
-------------------------
#!/usr/local/bin/perl -w
use IO::Socket::SSL;
use Mail::IMAPClient;
my $ssl = IO::Socket::SSL->new (Proto=>'tcp',
#SSL_verify_mod=>0x00,
PeerAddr=>"mailtest.mydomain.net",
PeerPort=>993);
print "SSL OK? " . (defined $ssl) . "\n";
print "SSL says: " . <$ssl> . "\n";
$imap = Mail::IMAPClient->new(Server => "mailtest.mydomain.net",
Socket => $ssl,
Timeout=>5,
User => "ggtest103z\@mydomain.net",
Password => "abcdef",
Debug => 1,
);
print STDERR " \'$@\' \'$!\' |" . (defined $imap) . "|\n";
$imap->State ($imap->Connected);
print "Set State : " . $imap->State . "\n";
$imap->login();
print "Logged in $!\n";
exit 0;
--------------------
Any idea what's happening here? I've tested the mail server and it
works fine via SSL.
Thanks.
-Greg G
| |
| Greg G 2005-05-31, 4:01 pm |
| Greg G wrote:
>
> I'm trying to get Mail::IMAPClient to work via SSL. I'm running into a
> problem. Here's the output:
>
> # ./imap_test.pl
> SSL OK? 1
> SSL says: * OK mailtest sendmail Server IMAP4rev1
> (2.1.5/smserver-2-1-5-build-1174)
>
> Using Mail::IMAPClient version 2.2.9 and perl version 5.8.6 (5.008006)
> '0' '' |1|
> Set State : 1
> Sending literal string in two parts: 1 Login "ggtest103z@mydomain.net" {6}
>
> then: abcdef
>
> Sending: 1 Login "XXXXXX" {6}
>
> Sent 38 bytes
> Can't call method "can_read" on an undefined value at
> /usr/local/lib/perl5/site_perl/5.8.6/Mail/IMAPClient.pm line 1583.
> #
> #
> then: abcdef
>
> Sending: 1 Login "XXXXXX" {6}
>
> Sent 38 bytes
> Can't call method "can_read" on an undefined value at
> /usr/local/lib/perl5/site_perl/5.8.6/Mail/IMAPClient.pm line 1583.
> #
> ---------------------------
> Here's the code:
>
> -------------------------
> #!/usr/local/bin/perl -w
>
> use IO::Socket::SSL;
> use Mail::IMAPClient;
>
>
> my $ssl = IO::Socket::SSL->new (Proto=>'tcp',
> #SSL_verify_mod=>0x00,
> PeerAddr=>"mailtest.mydomain.net",
> PeerPort=>993);
>
> print "SSL OK? " . (defined $ssl) . "\n";
>
> print "SSL says: " . <$ssl> . "\n";
>
> $imap = Mail::IMAPClient->new(Server => "mailtest.mydomain.net",
> Socket => $ssl,
> Timeout=>5,
> User => "ggtest103z\@mydomain.net",
> Password => "abcdef",
> Debug => 1,
> );
>
>
> print STDERR " '$@' '$!' |" . (defined $imap) . "|\n";
>
> $imap->State ($imap->Connected);
> print "Set State : " . $imap->State . "\n";
> $imap->login();
> print "Logged in $!\n";
>
> exit 0;
>
> --------------------
>
> Any idea what's happening here? I've tested the mail server and it
> works fine via SSL.
>
> Thanks.
>
> -Greg G
Anybody? I still can't get this to work...
-Greg G
| |
| Josef Moellers 2005-05-31, 4:01 pm |
| Greg G wrote:
> Greg G wrote:
>=20
[color=darkred]
[color=darkred]
=20[color=darkred]
>=20
>=20
> Anybody? I still can't get this to work...
I'm sorry if this isn't really the answer, I know too little of the=20
underlying protocol to analyze your problem in-depth, but I had problems =
with imaps myself and have discovered what I consider a bug in=20
/usr/lib/perl5/site_perl/5.8.1/Mail/IMAPClient.pm:
In sub login, I had to replace the "my $string =3D ..." with the followin=
g
my $string =3D "Login " . ( $has_quotes ? $id : qq("$id") )
. " " .
"{" . length($self->Password) .
"}\r\n" . $self->Password . "\r\n";
Maybe this helps (sure hope it does),
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
| |
| Tad McClellan 2005-05-31, 4:01 pm |
| Greg G <ggershSNACK@CAKEctc.net> wrote:
> Greg G wrote:
[color=darkred]
^ ^ ^ ^
Single quotes are not meta in a double quoted string, there is
no need to backslash them.
Outputting the return value from defined() is a strange thing
to do. What do you expect to be printed when it returns a
true value? What do you expect to be printed when it returns a
false value?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
| |
| Greg G 2005-05-31, 4:01 pm |
| Josef Moellers wrote:
> Greg G wrote:
>
>
>
> I'm sorry if this isn't really the answer, I know too little of the
> underlying protocol to analyze your problem in-depth, but I had problems
> with imaps myself and have discovered what I consider a bug in
> /usr/lib/perl5/site_perl/5.8.1/Mail/IMAPClient.pm:
>
> In sub login, I had to replace the "my $string = ..." with the following
>
> my $string = "Login " . ( $has_quotes ? $id : qq("$id") )
> . " " .
> "{" . length($self->Password) .
> "}\r\n" . $self->Password . "\r\n";
>
> Maybe this helps (sure hope it does),
>
> Josef
Unfortunately for me, this is exactly what's in there now. For
reference:
# $Id: IMAPClient.pm,v 20001010.20 2003/06/13 18:30:55 dkernen Exp $
$Mail::IMAPClient::VERSION = '2.2.9';
-Greg G
| |
| Greg G 2005-05-31, 4:01 pm |
| Tad McClellan wrote:
> Greg G <ggershSNACK@CAKEctc.net> wrote:
>
>
>
>
>
> ^ ^ ^ ^
>
> Single quotes are not meta in a double quoted string, there is
> no need to backslash them.
My experience is that if I don't escape the single-quotes, my
variables don't get printed.
> Outputting the return value from defined() is a strange thing
> to do. What do you expect to be printed when it returns a
> true value? What do you expect to be printed when it returns a
> false value?
I expect to get a "1" if $imap is defined and nothing if it's not.
Either way, this line has no effect on my code falling down.
-Greg G
| |
| Tad McClellan 2005-05-31, 4:01 pm |
| Greg G <ggershSNACK@CAKEctc.net> wrote:
> Tad McClellan wrote:
>
> My experience is that if I don't escape the single-quotes, my
> variables don't get printed.
You have entered the Twilight Zone then, as that cannot happen
unless there is something else going on that we've not been shown.
If you can reproduce a situation where that occurs, then please
post it here and we can help you understand whatever misunderstanding
it is that you are operating under.
>
> I expect to get a "1" if $imap is defined
You shouldn't expect that, as it can change at any perl revision.
defined() is documented to return only "a true value", not any
particular true value, so it may start returning 100 or 'is defined'
in the future.
Relying on undocumented features is not a good programming practice.
> Either way, this line has no effect on my code falling down.
Right, I did not say that it did.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
|
|
|
|
|