1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl
# Always be safe
use strict;
use warnings;
# Use the module
use Mail::IMAPClient;
use IO::Socket::SSL;
my $imap = Mail::IMAPClient->new(
Server => 'server.name.de',
User => 'xxxxxxxxxxxx',
Password => 'xxxxxxxxxx',
Port => 993,
Ssl => 1,
Uid => 1,
) or die "IMAP Failure: $@";
my $folders = $imap->folders
or die "List folders error: ", $imap->LastError, "\n";
print "Folders: @$folders\n";
$imap->logout
or die "Logout error: ", $imap->LastError, "\n";
1
2
3
4
5
6
7
Started at Mon Aug 3 16:44:36 2015
Using Mail::IMAPClient version 3.35 on perl 5.010001
Connecting with IO::Socket::SSL PeerAddr server.name.de PeerPort 993 Proto tcp Timeout 600 Debug 1
ERROR: Unable to connect to server.name.de: at /usr/local/share/perl5/Mail/IMAPClient.pm line 370.
Mail::IMAPClient::connect(Mail::IMAPClient=HASH(0x1851b98)) called at /usr/local/share/perl5/Mail/IMAPClient.pm line 313
Mail::IMAPClient::new("Mail::IMAPClient", "Server", "server.name.de", "User", "xxxxx", "Password", "xxxxxx", "Ssl", 1, ...) called at ./imaptest.pl line 12
IMAP Failure: Unable to connect to server.name.de: at ./imaptest.pl line 12.
1
2
3
4
5
6
7
IO::Socket::SSL->new (
...
# SSL_verify_mode => 'SSL_VERIFY_NONE', # nur zum Test probieren, ist sonst zu unsicher
SSL_ca_file => 'server.de.pem', # Zertifikat eibinden
SSL_verifycn_scheme => 'imap*,
...
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Always be safe
use strict;
use warnings;
# Use the module
use Mail::IMAPClient;
use IO::Socket::SSL;
my $imap = Mail::IMAPClient->new(
User => 'xxxxxxx',
Password => 'xxxxxxxx',
Uid => 1,
Debug => 1,
Socket => IO::Socket::SSL->new (
Proto => 'tcp',
PeerAddr => 'server.name.de',
PeerPort => 993,
SSL_verify_mode => 'SSL_VERIFY_PEER',
SSL_verifycn_scheme => 'imap',
),
) or die "IMAP Failure: $@";
# $imap->Socket($ssl);
# $imap->connect;
my $folders = $imap->folders
or die "List folders error: ", $imap->LastError, "\n";
print "Folders: @$folders\n";
$imap->logout
or die "Logout error: ", $imap->LastError, "\n";