- []
Тестируем SMTP AUTH PLAIN
Нужно было протестировать соединение SMTP с AUTH PLAIN. При таком типе аутентификации данные кодируются алгоритмом base64. В интернете полно примеров, но не все они рабочие. Запишу-ка я для себя действительно рабочий пример.
Получаем кодированную пару логин-пароль
$ perl -MMIME::Base64 -e 'print encode_base64("solga\@spamanagement.ru\0"."123");'
c29sZ2FAc3BhbWFuYWdlbWVudC5ydQAxMjM=
Тестируем соединение с exim из коммандной строки с эмуляцией IP
в ehlo я специально поставил значение локалхост - при написании клиентов электронной почты используйте правильное имя хоста-отправителя.
#exim -bh 81.211.49.12
**** SMTP testing session as if from host 81.211.49.12 **** but without any ident (RFC 1413) callback. **** This is not for real! >>> host in hosts_connection_nolog? no (option unset) >>> host in host_lookup? no (option unset) >>> host in host_reject_connection? no (option unset) >>> gethostbyname looked up these IP addresses: >>> name=localhost address=127.0.0.1 >>> host in "localhost:127.0.0.0/8"? no (end of list) >>> host in sender_unqualified_hosts? no (end of list) >>> host in recipient_unqualified_hosts? no (end of list) >>> host in helo_verify_hosts? no (option unset) >>> host in helo_try_verify_hosts? no (option unset) >>> host in helo_accept_junk_hosts? no (option unset) 220 tessanet.ru ESMTP Max Antonov (exim3)
ehlo localhost
>>> localhost in helo_lookup_domains? no (end of list) >>> host in pipelining_advertise_hosts? yes (matched "*") >>> host in auth_advertise_hosts? yes (matched "*") >>> host in tls_advertise_hosts? no (option unset) 250-tessanet.ru Hello localhost [81.211.49.12] 250-SIZE 15728640 250-PIPELINING 250-AUTH PLAIN LOGIN CRAM-MD5 250 HELP
AUTH PLAIN c29sZ2FAc3BhbWFuYWdlbWVudC5ydQAxMjM=
>>> auth_plain authenticator: >>> $auth1 = solga@spamanagement.ru >>> $auth2 = 123 >>> $1 = solga@spamanagement.ru >>> $2 = 123 >>> expanded string: yes 235 Authentication succeeded
mail from: solga@maximus.net
250 OK
rcpt to: max@tessart.ru
>>> using ACL "acl_check_rcpt"
>>> processing "accept"
>>> check hosts = :
>>> host in ":"? no (end of list)
>>> accept: condition test failed
>>> processing "deny"
>>> check domains = +local_domains
>>> tessart.ru in "tessart.ru"? yes (matched "tessart.ru")
>>> tessart.ru in "+local_domains"? yes (matched "+local_domains")
>>> check local_parts = ^[.] : ^.*[@%!/|]
>>> max in "^[.] : ^.*[@%!/|]"? no (end of list)
>>> deny: condition test failed
>>> processing "deny"
>>> check domains = !+local_domains
>>> tessart.ru in "tessart.ru"? yes (matched "tessart.ru")
>>> tessart.ru in "!+local_domains"? no (matched "!+local_domains")
>>> deny: condition test failed
>>> processing "warn"
>>> check condition = ${if eq{$sender_helo_name}{}{yes}{no}}
>>> = no
>>> warn: condition test failed
>>> processing "accept"
>>> check authenticated = *
>>> auth_plain in "*"? yes (matched "*")
>>> accept: condition test succeeded
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject: test letter X-Mailer: out-gluk-by-microsoft test message from telnet .
>>> using ACL "acl_check_data"
>>> processing "deny"
>>> check condition = ${if match{$message_body} {105[-_]*51[-_]*86|778[-_]*98[-_]*94} {yes}{no}}
>>> = no
>>> deny: condition test failed
>>> processing "deny"
>>> check demime = com:vbs:bat:pif:scr:exe:msi
>>> deny: condition test failed
>>> processing "accept"
>>> accept: condition test succeeded
>>> unspool_mbox(): unlinking '/var/spool/exim/scan/1JwHI4-0000hK-N5/1JwHI4-0000hK-N5.eml'
>>> unspool_mbox(): unlinking '/var/spool/exim/scan/1JwHI4-0000hK-N5/1JwHI4-0000hK-N5-00000.com'
LOG: 1JwHI4-0000hK-N5 <= solga@maximus.net H=(localhost) [81.211.49.12] P=esmtpa A=auth_plain:solga S=277 from <solga@maximus.net> for max@tessart.ru
250 OK id=1JwHI4-0000hK-N5
**** SMTP testing: that is not a real message id!
LOG: 1JwHI4-0000hK-N5 SMTP command timeout on connection from (localhost) [81.211.49.12]
421 tessanet.ru: SMTP command timeout - closing connection
Пояснение
Все это значит что я законнектился к экзим якобы с IP 81.211.49.12 - мне нужно было проверить как отрикошечивает этот IP и почему.
В этом случае не происходит реальной доставки сообщения, но exim реально проходит все стадии обработки письма.
В этом случае exim пишет отладочную информацию, логи и ответы сервера в STDOUT.

