QMail – Test (CentOS 7)
Testiamo il corretto funzionamento del nostro server di posta; partiamo creando un utente di test e vediamo cosa succede se proviamo a consegnargli una mail.
Creazione utente di test
# /home/vpopmail/bin/vadduser dave@anthesia.lan
Messaggio da sender inesistente
# yum -y install telnet # telnet mailtest.anthesia.lan 25 Trying 192.168.44.100... Connected to qmail.anthesia.lan. Escape character is '^]'. 220 qmail.anthesia.lan ESMTP helo anthesia.lan 250 qmail.anthesia.lan mail from: notexistentuser@notexistentdomain.com 550 5.1.8 sorry, can't find a valid MX for sender domain (chkuser)
Dal file di log /var/qmail/qmail-smtpd/current possiamo vedere che:
@40000000527bd6b51f9a242c tcpserver: status: 1/20 @40000000527bd6b51f9dfc8c tcpserver: pid 6911 from 192.168.44.100 @40000000527bd6b51fd7c19c tcpserver: ok 6911 qmail.anthesia.lan:192.168.44.100:25 :192.168.44.100::36472 @40000000527bd6cd37376234 CHKUSER rejected sender: from <notexistentuser@notexistentdomain.com::> remote <anthesia.lan:unknown:192.168.44.100> rcpt <> : invalid sender MX domain
Quindi il nostro server rifiuta correttamente messaggi inviati da untenti appartenenti a domini inesistenti restituendo come codice di errore 5.1.8.
Sender corretto ma destinatario (recipient) non esistente:
# telnet qmail.anthesia.lan 25 Trying 192.168.44.100... Connected to qmail.anthesia.lan. Escape character is '^]'. 220 qmail.anthesia.lan ESMTP helo anthesia.net 250 qmail.anthesia.lan mail from: notification@facebookmail.com 250 ok rcpt to: ciccio@anthesia.lan 550 5.1.1 sorry, no mailbox here by that name (chkuser)
Anche in questo caso il nostro server rifiuta il messaggio restituendo codice di errore 5.1.1.
Sender corretto e recipient valido:
# telnet qmail.anthesia.lan 25 Trying 192.168.44.100... Connected to qmail.anthesia.lan. Escape character is '^]'. 220 qmail.anthesia.lan ESMTP helo anthesia.lan 250 qmail.anthesia.lan mail from: notification+piledoh1@facebookmail.com 250 ok rcpt to: dave@anthesia.lan 250 ok DATA 354 go ahead From: notification+piledoh1@facebookmail.com To: dave@anthesia.lan Subject: Prova di mail Corpo della mail . 250 ok 1383848057 qp 6932
Dal file di log /var/qmail/qmail-smtpd/current:
@40000000527bd8411c93be14 tcpserver: status: 1/20
@40000000527bd8411c97ade4 tcpserver: pid 6929 from 192.168.44.100
@40000000527bd8411d46b294 tcpserver: ok 6929 qmail.anthesia.lan:192.168.44.100:25 :192.168.44.100::36476
@40000000527bd84d2eb340ec CHKUSER accepted sender: from <notification+piledoh1@facebookmail.com::> remote <anthesia.lan:unknown:192.168.44.100> rcpt <> : sender accepted
@40000000527bd852347e398c CHKUSER accepted rcpt: from <notification+piledoh1@facebookmail.com::> remote <anthesia.lan:unknown:192.168.44.100> rcpt <dave@anthesia.lan> : found existing recipient
@40000000527bd88307456594 mail recv: pid 6929 from <notification+piledoh1@facebookmail.com> qp 6932
@40000000527bd8830745697c qmail-smtpd: message accepted: notification+piledoh1@facebookmail.com from 192.168.44.100 to dave@anthesia.lan helo anthesia.lan
@40000000527bd88622b0747c tcpserver: end 6929 status 0
@40000000527bd88622b07864 tcpserver: status: 0/20
e dal file /var/log/qmail/qmail-send/current:
@40000000527bd83636489564 new msg 394053
@40000000527bd83636489564 info msg 394053: bytes 334 from <notification+piledoh1@facebookmail.com> qp 6923 uid 66
@40000000527bd8363648c82c starting delivery 1: msg 394053 to local anthesia.lan-dave@anthesia.lan
@40000000527bd8363648cc14 status: local 1/10 remote 0/20
@40000000527bd8363982501c delivery 1: success: did_0+0+1/
@40000000527bd8363983ceec status: local 0/10 remote 0/20
@40000000527bd836398cf2c4 end msg 394053
@40000000527bd88307953b14 new msg 394053
@40000000527bd88307953efc info msg 394053: bytes 398 from <notification+piledoh1@facebookmail.com> qp 6932 uid 66
@40000000527bd88307953efc starting delivery 2: msg 394053 to local anthesia.lan-dave@anthesia.lan
@40000000527bd883079542e4 status: local 1/10 remote 0/20
@40000000527bd8830811b644 delivery 2: success: did_0+0+1/
@40000000527bd8830812eadc status: local 0/10 remote 0/20
@40000000527bd883081315d4 end msg 394053
Quindi il nostro server funziona come ci aspettiamo.
Test su SMTP Auth
Testiamo ora il funzionamento dell'smtp autenticato sulla porta 587 con autenticazione "AUTH LOGIN". La prima cosa da fare è prendere l'encoding in base64 della username e della password che vogliamo usare per spedire mail: # printf "dave@anthesia.lan" | base64 ZGF2ZUBhbnRoZXNpYS5sYW4= <=== Encoding in base64 della username # printf "davepwd" | base64 ZGF2ZXB3ZA== <=== Encoding in base64 della password # openssl s_client -starttls smtp -crlf -connect 192.168.44.100:587 CONNECTED(00000003) depth=0 C = IT, ST = Italy, L = Florence, O = Anthesia Ltd, OU = IT Department, CN = qmail.anthesia.lan, emailAddress = dave@anthesia.lan verify error:num=18:self signed certificate verify return:1 depth=0 C = IT, ST = Italy, L = Florence, O = Anthesia Ltd, OU = IT Department, CN = qmail.anthesia.lan, emailAddress = dave@anthesia.lan verify return:1 --- Certificate chain 0 s:/C=IT/ST=Italy/L=Florence/O=Anthesia Ltd/OU=IT Department/CN=qmail.anthesia.lan/emailAddress=dave@anthesia.lan i:/C=IT/ST=Italy/L=Florence/O=Anthesia Ltd/OU=IT Department/CN=qmail.anthesia.lan/emailAddress=dave@anthesia.lan --- Server certificate -----BEGIN CERTIFICATE----- MIIEETCCAvmgAwIBAgIJAMopHbPcqa5fMA0GCSqGSIb3DQEBBQUAMIGeMQswCQYD VQQGEwJJVDEOMAwGA1UECAwFSXRhbHkxETAPBgNVBAcMCEZsb3JlbmNlMRUwEwYD VQQKDAxBbnRoZXNpYSBMdGQxFjAUBgNVBAsMDUlUIERlcGFydG1lbnQxGzAZBgNV BAMMEnFtYWlsLmFudGhlc2lhLmxhbjEgMB4GCSqGSIb3DQEJARYRZGF2ZUBhbnRo ZXNpYS5sYW4wHhcNMTMxMTA3MTY1MDIzWhcNMjMxMTE1MTY1MDIzWjCBnjELMAkG A1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MREwDwYDVQQHDAhGbG9yZW5jZTEVMBMG A1UECgwMQW50aGVzaWEgTHRkMRYwFAYDVQQLDA1JVCBEZXBhcnRtZW50MRswGQYD VQQDDBJxbWFpbC5hbnRoZXNpYS5sYW4xIDAeBgkqhkiG9w0BCQEWEWRhdmVAYW50 aGVzaWEubGFuMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+Iq0jB3Z zFmfqdJSBo9uRCGpvl8HwOOPXi2V3hHPr6wDcbMv82lwZksHqQLCSjHpjSWWy5jy CrT9fYchPGL4DuE3GZH7gBLAwxJLClUnCbJMcSb3O3iw1EUcXC9l6DrafhClmt6Z c6C98t3BnqrXxNqtj72n/fkGJjragFA4tM/eV30GHx18VS+z3MjDFKoimrBuXHuI hLaH4iwEl4mimWzhkR6qS9AHdiTUUZcSwd27p6XF0d5LqYzcks2TDfcVWYngvp6I vfAaM7ujVwBB0jxmlLsymheJjH251l5hEwQbqzcZJjlOESx247AILEq0Pqn3w+++ S5YXDtOLyQnuJQIDAQABo1AwTjAdBgNVHQ4EFgQUxIfCxacXEDKmSSwmqSVy9I3Y ZdkwHwYDVR0jBBgwFoAUxIfCxacXEDKmSSwmqSVy9I3YZdkwDAYDVR0TBAUwAwEB /zANBgkqhkiG9w0BAQUFAAOCAQEAjrVR6uHTpgqSY+WL8lM+V/RFWNMPz0/SzaGR NqyAUZJ9xQJaPhcm6AXMA45tphopZigICuQJfU9inVmRQqf5tg/kZHPbnZlBvOcj ZQjfwIjMKJ/Q5WPht58XRQi4IcozmXjJr0twCwoAzoe5bHRhyEdmmjsEe1gBN0cd ogi8u51iM/2JZJQQVxcG8IfDhsZfQ5/xtbZGpzVjqRwbDP/Bnn338BTdvfO4IMSN x6uIjxePBtglyEVIdjyKV1NOARHaQMJ6HNYRZ4JsbFWPeBdb3Px9AVXl8wkvZteu y9d5ALGCnT2ZDkCN1ZgGRl0JnUnYJfhZHckhfvOr6Y6tnbOIsw== -----END CERTIFICATE----- subject=/C=IT/ST=Italy/L=Florence/O=Anthesia Ltd/OU=IT Department/CN=qmail.anthesia.lan/emailAddress=dave@anthesia.lan issuer=/C=IT/ST=Italy/L=Florence/O=Anthesia Ltd/OU=IT Department/CN=qmail.anthesia.lan/emailAddress=dave@anthesia.lan --- No client certificate CA names sent --- SSL handshake has read 2027 bytes and written 345 bytes --- New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA Server public key is 2048 bit Secure Renegotiation IS supported Compression: NONE Expansion: NONE SSL-Session: Protocol : TLSv1 Cipher : DHE-RSA-AES256-SHA Session-ID: AFCF67C130AA4CED59F2B04B5387EDD9B96141D2641CEF07007E1BC951BB4604 Session-ID-ctx: Master-Key: 423D5F68183235790886C207C0503F4D2370450D366840BA9880B60BD4D72B0A5E926B920A77B5A07AD95DB2EB9E8431 Key-Arg : None Krb5 Principal: None PSK identity: None PSK identity hint: None TLS session ticket: 0000 - a0 07 59 35 ca 92 82 87-a6 29 e9 6d 13 40 3d ed ..Y5.....).m.@=. 0010 - 5e 90 46 50 22 82 a0 54-9e b8 76 97 28 50 16 b4 ^.FP"..T..v.(P.. 0020 - 31 4e ed 0f 96 7e da 25-c2 ec bc ff 48 a3 de d1 1N...~.%....H... 0030 - a0 58 fb f2 bf b7 ac 04-5f a6 67 74 97 41 37 05 .X......_.gt.A7. 0040 - ae fb 1d 3d c1 f3 9e a1-63 37 b2 e6 f7 b3 51 70 ...=....c7....Qp 0050 - 2d 4c 0d 54 b3 e8 35 53-d9 70 63 5a e7 7e 2c b6 -L.T..5S.pcZ.~,. 0060 - ea ed 33 9c 0a bf 31 72-6f 5a 05 27 fc 95 2e 82 ..3...1roZ.'.... 0070 - cf 89 13 a9 73 28 2e 1d-f3 ac 56 ed 10 e6 ad 15 ....s(....V..... 0080 - 13 2d 6b 1a bb 52 74 aa-62 08 80 32 f5 6a 9d 74 .-k..Rt.b..2.j.t 0090 - f7 af c4 13 65 0b af 45-58 fb 72 ee 0c 52 c3 f9 ....e..EX.r..R.. Start Time: 1383850820 Timeout : 300 (sec) Verify return code: 18 (self signed certificate) --- 250 SIZE 20000000 auth login 334 VXNlcm5hbWU6 ZGF2ZUBhbnRoZXNpYS5sYW4= <=== Inseriamo la nostra username in base64 334 UGFzc3dvcmQ6 ZGF2ZXB3ZA== <=== Inseriamo la nostra password in base64 235 ok, go ahead (#2.0.0) mail from: lellothemagic@anthesia.lan 250 ok rcpt to: dave@anthesia.lan 250 ok data 354 go ahead subject: test mail to: dave@anthesia.lan from: lellothemagic@anthesia.lan Messaggio di test inviato tramite telnet . 250 ok 1383850940 qp 7102
Anche in questo caso in nostro server funziona come da aspettative.
Vedremo ora come integrare nel server di posta il controllo fondamentale per antivirus e antispam