Thunderbird does not connect to Postfix/Dovecot.
My webmail interface works with login (name#domain.tld + password),
incoming (SSL/TLS, Port 993) and outgoing messages (STARTTLS, Port 587).
I did a bit debugging and got to know that it must be a certificate error.
Does anyone here know how to fix it, please?
This is my mail.log with SSL debugging:
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: elliptic curve secp384r1 will be used for ECDH and ECDHE key exchanges
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: elliptic curve secp384r1 will be used for ECDH and ECDHE key exchanges
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x10, ret=1: before/accept initialization [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: before/accept initialization [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2002, ret=-1: unknown state [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: SSLv3 read client hello A [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: SSLv3 write server hello A [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: SSLv3 write certificate A [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: SSLv3 write key exchange A [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: SSLv3 write server done A [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2001, ret=1: SSLv3 flush data [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2002, ret=-1: SSLv3 read client certificate A [x.x.x.x]
Apr 26 16:57:28 m123851 dovecot: imap-login: Debug: SSL: where=0x2002, ret=-1: SSLv3 read client certificate A [x.x.x.x]
Apr 26 16:57:29 m123851 dovecot: imap-login: Warning: SSL alert: where=0x4004, ret=560: fatal unknown CA [x.x.x.x]
Apr 26 16:57:29 m123851 dovecot: imap-login: Warning: SSL failed: where=0x2002: SSLv3 read client certificate A [x.x.x.x]
Apr 26 16:57:29 m123851 dovecot: imap-login: Disconnected (no auth attempts in 1 secs): user=<>, rip=192.x.x.x, lip=85.x.x.x, TLS handshaking: SSL_accept() failed: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca: SSL alert number 48, session=<NDYo2aEUWQAfBhbN>
This is my Dovecot ssl-config file (/etc/dovecot/conf.d/10-ssl.conf):
# Log SSL problems
verbose_ssl = yes
ssl = required
ssl_cert = </etc/dovecot/dovecot.pem
ssl_key = </etc/dovecot/private/dovecot.pem
ssl_protocols = !SSLv3 !SSLv2
ssl_cipher_list = EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+
SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+
CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:
!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:
AES256-SHA:CAMELLIA128-SHA:AES128-SHA
ssl_prefer_server_ciphers = yes
The SSL cert for Dovecot is setup for localhost.
As I tried to integrate my root ca and domain cert into the dovecot cert, the problem remains:
dovecot.pem cert = dovecot cert content + domain cert content + root ca cert content (exactly in this order from top to bottom)
dovecot.pem key = dovecot cert key + domain cert key + root ca cert key (exactly in this order from top to bottom)
Thunderbird is expecting dovecot to supply it with the certs it needs to verify the connection (intermediary certs or the self-signed CA cert). Check out "Chained SSL certificates" in http://wiki2.dovecot.org/SSL/DovecotConfiguration.
You can fix this by adding intermediary certs to your SSL cert file (/etc/ssl/certs/imap.pem or wherever your ssl_cert) is pointing. If you obtained your SSL certificate from a vendor, they should have instructions on how to obtain the intermediary certs.
Related
i've got a problem configuring sendmail to send email through smtp.
My goal is to have the ability to send mail from a php application using smtp.
I've to migrate to a new server some old legacy php application which use the standard "mail()" php function, and i can't modify the code, so i can't just use something like "phpMailer" or "pear mail package" instead.
I've followed this guide (venice answer) sendmail: how to configure sendmail on ubuntu? , and watched many other that say the same thing...
I've already installed and configured sendmail, and it works fine for sending local mail (if i send an email to root#localhost, i receive it correctly) but not for sending "normal" email..
Every time i send an email i've got these error in the mail.log file:
Nov 26 15:38:17 compute-prod-main-2-vm sm-mta[22434]: xAQFcH3g022434: from=<Mattia#compute-prod-main-2-vm.europe-west1-b.c.fine-command-242712.in>, size=418, class=0, nrcpts=1, msgid=<201911261538.xAQFcHXA022433#compute-prod-main-2-vm.europe-west1-b.c.fine-command-242712.in>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Nov 26 15:38:17 compute-prod-main-2-vm sendmail[22433]: xAQFcHXA022433: to=mattiabonzi#libero.it, ctladdr=Mattia (1002/1005), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30105, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (xAQFcH3g022434 Message accepted for delivery)
Nov 26 15:38:33 compute-prod-main-2-vm sendmail[22444]: xAQFcXYx022444: from=Mattia, size=80, class=0, nrcpts=1, msgid=<201911261538.xAQFcXYx022444#compute-prod-main-2-vm.europe-west1-b.c.fine-command-242712.in>, relay=root#localhost
Nov 26 15:38:33 compute-prod-main-2-vm sm-mta[22445]: xAQFcXOb022445: from=<Mattia#compute-prod-main-2-vm.europe-west1-b.c.fine-command-242712.in>, size=469, class=0, nrcpts=1, msgid=<201911261538.xAQFcXYx022444#compute-prod-main-2-vm.europe-west1-b.c.fine-command-242712.in>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Nov 26 15:38:33 compute-prod-main-2-vm sendmail[22444]: xAQFcXYx022444: to=mattiabonzi#openworks.it, ctladdr=Mattia (1002/1005), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30080, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (xAQFcXOb022445 Message accepted for delivery)
Nov 26 15:38:37 compute-prod-main-2-vm sm-mta[21588]: xAQFXbC8021586: timeout waiting for input from authsmtp.securemail.pro during client greeting
Nov 26 15:38:37 compute-prod-main-2-vm sm-mta[21588]: xAQFXbC8021586: to=<mattiabonzi#libero.it>, delay=00:05:00, xdelay=00:05:00, mailer=relay, pri=120418, relay=authsmtp.securemail.pro [81.88.48.66], dsn=4.0.0, stat=Deferred: Connection timed out with authsmtp.securemail.pro
Nov 26 15:41:00 compute-prod-main-2-vm sm-mta[21743]: xAQFa0cV021741: timeout waiting for input from authsmtp.securemail.pro during client greeting
Nov 26 15:41:00 compute-prod-main-2-vm sm-mta[21743]: xAQFa0cV021741: to=<mattiabonzi#libero.it>, delay=00:05:00, xdelay=00:05:00, mailer=relay, pri=120418, relay=authsmtp.securemail.pro [81.88.48.66], dsn=4.0.0, stat=Deferred: Connection timed out with authsmtp.securemail.pro
Nov 26 15:42:02 compute-prod-main-2-vm sm-mta[21765]: xAQFb1PN021763: timeout waiting for input from authsmtp.securemail.pro during client greeting
Nov 26 15:42:02 compute-prod-main-2-vm sm-mta[21765]: xAQFb1PN021763: to=<mattiabonzi#libero.it>, delay=00:05:01, xdelay=00:05:01, mailer=relay, pri=120418, relay=authsmtp.securemail.pro [81.88.48.66], dsn=4.0.0, stat=Deferred: Connection timed out with authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQFNe4X021461: to=<mattiabonzi#libero.it>, delay=00:19:26, xdelay=00:05:00, mailer=relay, pri=210466, relay=authsmtp.securemail.pro [81.88.48.66], dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQFH7gj020614: to=<mattiabonzi#libero.it>, delay=00:25:59, xdelay=00:00:00, mailer=relay, pri=300466, relay=authsmtp.securemail.pro, dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQFBfZq020461: to=<mattiabonzi#openworks.it>, delay=00:31:25, xdelay=00:00:00, mailer=relay, pri=300469, relay=authsmtp.securemail.pro, dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQEkePb016232: to=<mattiabonzi#openworks.it>, delay=00:56:26, xdelay=00:00:00, mailer=relay, pri=390469, relay=authsmtp.securemail.pro, dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQEkfdA016262: to=<mattiabonzi#openworks.it>, delay=00:56:25, xdelay=00:00:00, mailer=relay, pri=390469, relay=authsmtp.securemail.pro, dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQEkgiG016272: to=<mattiabonzi#openworks.it>, delay=00:56:24, xdelay=00:00:00, mailer=relay, pri=390469, relay=authsmtp.securemail.pro, dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
Nov 26 15:43:06 compute-prod-main-2-vm sm-mta[22415]: xAQEkfEJ016252: to=<mattiabonzi#openworks.it>, delay=00:56:25, xdelay=00:00:00, mailer=relay, pri=390469, relay=authsmtp.securemail.pro, dsn=4.0.0, stat=Deferred: Connection reset by authsmtp.securemail.pro
This is what i've initialy added to the sendmail.mc file
define(`SMART_HOST',`authsmtp.securemail.pro')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
I've made some research and understood that the problem may be the port that sendmail is using for the smtp connection.
i've tried to telnet my isp and i'm able to contact it only on port 465, but i cannot find a way to change the port that sendmail is using.
I've tried to add those line, but with no luck:
define(`ESMTP_MAILER_ARGS', `TCP $h 465')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 465')dnl
I've also noticed that one antoher server that i have with sendmal instaled and propely configured is using the mailer esmtp, this installation use insted relay, is that normal?
What i'm doing wrong?
Thank yuo in advance, hope that i've listed all the relevant details.
First find more info. Force delivery retry in verbose mode with SMTP session tracking.
It provides useful hints in most cases (well above 50% based on my experience).
To push email with queue id xAQEkfEJ016252 as root execute the following command:
sendmail -v -qIxAQEkfEJ016252
I have a VPS server running Ubunutu16 + Plesk.
Webmail Roundcube starts without issues.
I created one email account admin#mydomain.com
I can send only the mail from admin#mydomain.com to admin
Sending mail to the server and from the server to my gmail and other accounts are not working.
in the /var/log/maillog I see timeouts like below.
Jan 11 19:20:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
Jan 11 19:21:13 localhost dovecot: imap-login: Login: user=<admin#mydomain.de>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=1909, TLS, session=<sh4nmTN/7q9/AAAB>
Jan 11 19:21:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
Jan 11 19:22:13 localhost dovecot: imap-login: Login: user=<admin#mydomain.de>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=1914, TLS, session=<adS6nDN/8q9/AAAB>
Jan 11 19:22:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
Jan 11 19:23:13 localhost dovecot: imap-login: Login: user=<admin#mydomain.de>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=1918, TLS, session=<+EtOoDN/+q9/AAAB>
Jan 11 19:23:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
Jan 11 19:24:13 localhost dovecot: imap-login: Login: user=<admin#mydomain.de>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=1922, TLS, session=<ltLhozN/ArB/AAAB>
Jan 11 19:24:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
Jan 11 19:25:13 localhost dovecot: imap-login: Login: user=<admin#mydomain.de>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=1931, TLS, session=<oWl1pzN/BrB/AAAB>
Jan 11 19:25:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
Jan 11 19:25:37 localhost postfix/qmgr[1235]: 22EA062BD2: from=<admin#mydomain.de>, size=613, nrcpt=1 (queue active)
Jan 11 19:25:37 localhost postfix/qmgr[1235]: 50E9362CEB: from=<admin#mydomain.de>, size=599, nrcpt=1 (queue active)
Jan 11 19:26:07 localhost postfix/smtp[1971]: connect to mx00.emig.gmx.net[212.227.15.9]:25: Connection timed out
Jan 11 19:26:07 localhost postfix/smtp[1972]: connect to mx00.emig.gmx.net[212.227.15.9]:25: Connection timed out
Jan 11 19:26:13 localhost dovecot: imap-login: Login: user=<admin#mydomain.de>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=2034, TLS, session=<OB8JqzN/HrB/AAAB>
Jan 11 19:26:13 localhost dovecot: service=imap, user=admin#mydomain.de, ip=[127.0.0.1]. Logged out rcvd=50, sent=512
root#localhost:/var/log# telnet alt4.gmail-smtp-in.l.google.com 25
Solved
After I have set MX record in DNS records error disappeared.
I am trying to send a mail with a non root user (also by tuleap application) but i have some trouble.
when we use a root user with command
echo “TR : This is a test of sending mail” | mail -s Test <mail>
it return this log and my email is sent
Mar 10 16:59:09 localhost sendmail[11969]: t2AGx9Up011969: from=root, size=258, class=0, nrcpts=1, msgid=<201503101659.t2AGx9Up011969#localhost.localdomain>, relay=root#localhost
Mar 10 16:59:09 localhost sendmail[11970]: t2AGx9Js011970: from=<root#localhost.localdomain>, size=521, class=0, nrcpts=1, msgid=<201503101659.t2AGx9Up011969#localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Mar 10 16:59:09 localhost sendmail[11969]: t2AGx9Up011969: to=<my mail>, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30258, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t2AGx9Js011970 Message accepted for delivery)
Mar 10 16:59:12 localhost sendmail[11972]: STARTTLS=client, relay=<my SMTP server>, version=TLSv1/SSLv3, verify=OK, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Mar 10 16:59:15 localhost sendmail[11972]: t2AGx9Js011970: to=<my mail>, ctladdr=<root#localhost.localdomain> (0/0), delay=00:00:06, xdelay=00:00:06, mailer=relay, pri=120521, relay=<my SMTP server> [IP], dsn=2.0.0, stat=Sent (OK id=1YVNUv-002ihW-JJ)
but when we use an other use (like codendiadm as used by tuleap) with the same command, it return this log without sending mail
Mar 10 16:59:53 localhost sendmail[12024]: t2AGxrhg012024: from=codendiadm, size=258, class=0, nrcpts=1, msgid=<201503101659.t2AGxrhg012024#localhost.localdomain>, relay=codendiadm#localhost
Mar 10 16:59:53 localhost sendmail[12025]: t2AGxr16012025: from=<codendiadm#localhost.localdomain>, size=556, class=0, nrcpts=1, msgid=<201503101659.t2AGxrhg012024#localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Mar 10 16:59:53 localhost sendmail[12024]: t2AGxrhg012024: to=<my mail>, ctladdr=codendiadm (495/492), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30258, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t2AGxr16012025 Message accepted for delivery)
Mar 10 16:59:57 localhost sendmail[12027]: STARTTLS=client, relay=<my SMTP server>, version=TLSv1/SSLv3, verify=OK, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Mar 10 17:00:00 localhost sendmail[12027]: t2AGxr16012025: to=<my mail>, ctladdr=<codendiadm#localhost.localdomain> (495/492), delay=00:00:07, xdelay=00:00:07, mailer=relay, pri=120556, relay=<my SMTP server> [IP], dsn=5.1.1, stat=User unknown
Mar 10 17:00:00 localhost sendmail[12027]: t2AGxr16012025: t2AH0016012027: DSN: User unknown
Try to remove sendmail and install postfix instead. And tell me if it works better this way. You'll find how to do it here.
i am trying to configure kamailio on my locak systen .
i have installed kamailio on my linux i getting call properly. but when i try to connect by tls getting following errors in log file.
ct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: rtpproxy [rtpproxy.c:1592]: rtpp_test(): rtp proxy <udp:127.0.0.1:7722> found, support for it enabled
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:275]: fill_missing(): TLSs<default>: tls_method=9
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:287]: fill_missing(): TLSs<default>: certificate='/etc/kamailio/server.crt'
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:294]: fill_missing(): TLSs<default>: ca_list='/etc/kamailio/servercakey.pem'
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:301]: fill_missing(): TLSs<default>: crl='(null)'
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:305]: fill_missing(): TLSs<default>: require_certificate=0
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:312]: fill_missing(): TLSs<default>: cipher_list='(null)'
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:319]: fill_missing(): TLSs<default>: private_key='/etc/kamailio/server.key'
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:323]: fill_missing(): TLSs<default>: verify_certificate=0
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: INFO: tls [tls_domain.c:326]: fill_missing(): TLSs<default>: verify_depth=9
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: ERROR: tls [tls_domain.c:535]: load_ca_list(): TLSs<default>: Unable to load CA list '/etc/kamailio/servercakey.pem'
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: ERROR: <core> [sr_module.c:927]: init_mod_child(): init_mod_child(): Error while initializing module tls (/usr/lib64/kamailio/modules/tls.so)
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: ERROR: <core> [sr_module.c:927]: init_mod_child(): init_mod_child(): Error while initializing module tls (/usr/lib64/kamailio/modules/tls.so)
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: ERROR: <core> [main.c:1575]: main_loop(): ERROR: main: error in init_child(PROC_INT) -- exiting
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: ERROR: ctl [ctl.c:379]: mod_destroy(): ERROR: ctl: could not delete unix socket /tmp/kamailio_ctl: Operation not permitted (1)
i tried to generate new certificate , done already 3 times but still getting some error.
i need experts help. please guide me .
The problem is that you provide a path to a Certificate Authority (CA) file that doesn't exist or has broken content:
Oct 21 12:12:48 localhost /usr/sbin/kamailio[3612]: ERROR: tls [tls_domain.c:535]: load_ca_list(): TLSs<default>: Unable to load CA list '/etc/kamailio/servercakey.pem'
Either put the right path or file content if you used custom CA or just comment ca_list parameter if you want to work with default operating system (openssl lib) CA list.
I've currently got a bash script that parses /var/log/mail.log to determine the last login time/date of a imap user. I've determined Perl is going to be a lot more efficient and quicker for this task, especially as the logs grow.
Given the following example /var/log/mail.log file:
Jul 5 06:57:54 mail-04 dovecot: imap-login: Login: user=<user#foobar.com.au>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 06:59:54 mail-04 dovecot: imap-login: Login: user=<user#foobar.com.au>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 06:59:59 mail-04 dovecot: imap-login: Login: user=<otheruser#foobar.com.au>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 07:01:54 mail-04 dovecot: imap-login: Login: user=<user#foobar.com.au>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
Jul 5 07:01:59 mail-04 dovecot: imap-login: Login: user=<otheruser#foobar.com.au>, method=PLAIN, rip=192.168.x.x, lip=192.168.x.x
What is the most efficient way in Perl to print the last login time of each unique user? E.g. the expected output should be:
user#foobar.com.au last imap-login: Jul 5 07:01:54
otheruser#foobar.com.au last imap-login: Jul 5 07:01:59
Using a hash and keep assigning the login time to the user name sounds like a simple solution.
$logins{$username} = $date
perl -ne '$l{$2}=$1 if /^(.{15}) .* imap-login: Login: user=<([^>]+)>/; END { print "$_ last imap-login: $l{$_}\n" for keys %l }' /var/log/mail.log