не отправляется почта с localhost
Добавлено: 2009-10-30 21:20:59
Здравствуйте! Прошу знающих людей помочь, потому как уже несколько дней не могу решить проблему, похоже зашел в тупик...
Есть Exim 4.69 и база доменов и юзеров в Mysql. Также используется courier-imap и веб-морда Roundcube.
Настраивал связку по http://www.lissyara.su/?id=1175 в совокупности с гуглом
В итоге, все работает вроде бы нормально, почта приходит, уходит, работают различные клиенты (outlook, bat и тд).
Но (!) есть два неприятных момента:
1) на мой взгляд долго обрабатываются письма, бывает минута = письмо.... Пока поток писем ничтожно мал, но это пока сервер еще не в продакшне.
но эта даже не столь важно, важнее второе:
2) а этом же сервере есть сайт, в котором есть скрипт обратной связи:
он коннектится на localhost от определенного юзера и шлет другому юзеру письмо, заполненное посетителем сайта в специальной формочке. Посетитель также указывает и свой e-mail, на который потом посылается ответ. У скрипта есть настройки: может слать через SMTP сервер, через функцию php mailto или через sendmail.
Вот этот скрипт и не работает с exim'ом (через mailto все работает без проблем, но надо чтоб именно через мой ходила). Причем, он работает через всякие smtp.ru и тд, через мой exim же - не хочет. Все заканчивается 421 ошибкой.... lost input connection (connection reset by peer). Ищу ошибки, запустив exim -bd -d+all.
Привожу логи из дебага:
приведу конфиг для полноты картины:
Заранее признателен за любую помощь, в том числе в оформлении сообщения (особенно как сделать разворачиваемый код ).
Есть Exim 4.69 и база доменов и юзеров в Mysql. Также используется courier-imap и веб-морда Roundcube.
Настраивал связку по http://www.lissyara.su/?id=1175 в совокупности с гуглом
В итоге, все работает вроде бы нормально, почта приходит, уходит, работают различные клиенты (outlook, bat и тд).
Но (!) есть два неприятных момента:
1) на мой взгляд долго обрабатываются письма, бывает минута = письмо.... Пока поток писем ничтожно мал, но это пока сервер еще не в продакшне.
но эта даже не столь важно, важнее второе:
2) а этом же сервере есть сайт, в котором есть скрипт обратной связи:
он коннектится на localhost от определенного юзера и шлет другому юзеру письмо, заполненное посетителем сайта в специальной формочке. Посетитель также указывает и свой e-mail, на который потом посылается ответ. У скрипта есть настройки: может слать через SMTP сервер, через функцию php mailto или через sendmail.
Вот этот скрипт и не работает с exim'ом (через mailto все работает без проблем, но надо чтоб именно через мой ходила). Причем, он работает через всякие smtp.ru и тд, через мой exim же - не хочет. Все заканчивается 421 ошибкой.... lost input connection (connection reset by peer). Ищу ошибки, запустив exim -bd -d+all.
Привожу логи из дебага:
Код: Выделить всё
my_host# exim -bd -d+all
00:20:42 32300 Exim version 4.69 (FreeBSD 7.2) uid=0 gid=0 pid=32300 D=fffdffff
Probably Berkeley DB version 1.8x (native mode)
Support for: crypteq iconv() IPv6 use_setclassresources PAM Perl Expand_dlfunc OpenSSL Content_Scanning Old_Demime
Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz dnsdb dsearch mysql nis nis0 passwd
Authenticators: cram_md5 dovecot plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore/mbx autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
00:20:42 32300 changed uid/gid: forcing real = effective
00:20:42 32300 uid=0 gid=0 pid=32300
00:20:42 32300 auxiliary group list: 0
00:20:42 32300 seeking password data for user "mailnull": using cached result
00:20:42 32300 getpwnam() succeeded uid=26 gid=26
00:20:42 32300 seeking password data for user "root": cache not available
00:20:42 32300 getpwnam() succeeded uid=0 gid=0
00:20:42 32300 configuration file is /usr/local/etc/exim/configure
00:20:42 32300 log selectors = 0000cefe 00233821
00:20:42 32300 cwd=/usr/local/etc/exim 3 args: exim -bd -d+all
00:20:42 32300 trusted user
00:20:42 32300 admin user
00:20:42 32300 originator: uid=0 gid=0 login=root name=Charlie Root
00:20:42 32300 LOG: MAIN
00:20:42 32300 IPv6 socket creation failed: Protocol not supported
00:20:42 32300 LOG: MAIN
00:20:42 32300 Failed to create IPv6 socket for wildcard listening (Protocol not supported): will use IPv4
00:20:42 32300 listening on all interfaces (IPv4) port 25
00:20:42 32300 pid written to /var/run/exim.pid
00:20:42 32300 changed uid/gid: running as a daemon
00:20:42 32300 uid=26 gid=6 pid=32300
00:20:42 32300 auxiliary group list: 6 6
00:20:42 32300 LOG: MAIN
00:20:42 32300 exim 4.69 daemon started: pid=32300, no queue runs, listening for SMTP on port 25 (IPv4)
00:20:42 32300 set_process_info: 32300 daemon: no queue runs, listening for SMTP on port 25 (IPv4)
00:20:42 32300 daemon running with uid=26 gid=6 euid=26 egid=6
00:20:42 32300 Listening...
00:21:57 32300 Connection request from 127.0.0.1 port 51272
00:21:57 32300 interface address=127.0.0.1 port=25
00:21:57 32300 search_tidyup called
00:21:57 32300 1 SMTP accept process running
00:21:57 32300 Listening...
00:21:57 32302 sender_fullhost = [127.0.0.1]
00:21:57 32302 sender_rcvhost = [127.0.0.1]
00:21:57 32302 Process 32302 is handling incoming connection from [127.0.0.1]
00:21:57 32302 host in host_lookup? no (matched "!127.0.0.1")
00:21:57 32302 set_process_info: 32302 handling incoming connection from [127.0.0.1] I=[127.0.0.1]:25
00:21:57 32302 host in host_reject_connection? no (option unset)
00:21:57 32302 host in sender_unqualified_hosts? no (option unset)
00:21:57 32302 host in recipient_unqualified_hosts? no (option unset)
00:21:57 32302 host in helo_verify_hosts? no (option unset)
00:21:57 32302 host in helo_try_verify_hosts? no (option unset)
00:21:57 32302 host in helo_accept_junk_hosts? no (option unset)
00:21:57 32302 using ACL "acl_check_connect"
00:21:57 32302 processing "accept"
00:21:57 32302 check hosts = 127.0.0.1:localhost:my_host.ru
00:21:57 32302 host in "127.0.0.1:localhost:my_host.ru"? yes (matched "127.0.0.1")
00:21:57 32302 check control = no_enforce_sync
00:21:57 32302 accept: condition test succeeded
00:21:57 32302 expanding: $primary_hostname, ESMTP EXIM $version_number
00:21:57 32302 result: my_host.ru, ESMTP EXIM 4.69
00:21:57 32302 SMTP>> 220 my_host.ru, ESMTP EXIM 4.69
00:21:57 32302 Process 32302 is ready for new message
00:21:57 32302 smtp_setup_msg entered
00:21:57 32302 SMTP<< EHLO www.my_host.ru
00:21:57 32302 www.my_host.ru in helo_lookup_domains? no (end of list)
00:21:57 32302 sender_fullhost = (www.my_host.ru) [127.0.0.1]
00:21:57 32302 sender_rcvhost = [127.0.0.1] (helo=www.my_host.ru)
00:21:57 32302 set_process_info: 32302 handling incoming connection from (www.my_host.ru) [127.0.0.1] I=[127.0.0.1]:25
00:21:57 32302 host in pipelining_advertise_hosts? yes (matched "*")
00:21:57 32302 host in auth_advertise_hosts? yes (matched "*")
00:21:57 32302 host in tls_advertise_hosts? no (option unset)
00:21:57 32302 SMTP>> 250-my_host.ru Hello www.my_host.ru [127.0.0.1]
00:21:57 32302 250-SIZE 52428800
00:21:57 32302 250-PIPELINING
00:21:57 32302 250-AUTH PLAIN LOGIN CRAM-MD5
00:21:57 32302 250 HELP
00:21:57 32302 SMTP<< MAIL FROM:<frosty@mail_serv.com>
00:21:57 32302 SMTP>> 250 OK
00:21:57 32302 SMTP<< RCPT TO:<user@my_host.ru>
00:21:57 32302 using ACL "acl_check_rcpt"
00:21:57 32302 processing "accept"
00:21:57 32302 check hosts = :
00:21:57 32302 host in ":"? no (end of list)
00:21:57 32302 accept: condition test failed
00:21:57 32302 processing "deny"
00:21:57 32302 check domains = +local_domains
00:21:57 32302 expanding: SELECT `domain` FROM `domain` WHERE `domain`='${domain}' AND `active`='1'
00:21:57 32302 result: SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'
00:21:57 32302 search_open: mysql "NULL"
00:21:57 32302 search_find: file="NULL"
00:21:57 32302 key="SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'" partial=-1 affix=NULL starflags=0
00:21:57 32302 LRU list:
00:21:57 32302 internal_search_find: file="NULL"
00:21:57 32302 type=mysql key="SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'"
00:21:57 32302 database lookup required for SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'
00:21:57 32302 MySQL query: SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'
00:21:57 32302 MYSQL new connection: host=localhost port=0 socket=NULL database=***** user=*****
00:21:57 32302 lookup yielded: my_host.ru
00:21:57 32302 expanding: ${lookup mysql{SELECT `domain` FROM `domain` WHERE `domain`='${domain}' AND `active`='1'}}
00:21:57 32302 result: my_host.ru
00:21:57 32302 my_host.ru in "my_host.ru"? yes (matched "my_host.ru")
00:21:57 32302 my_host.ru in "+local_domains"? yes (matched "+local_domains")
00:21:57 32302 check local_parts = ^[.] : ^.*[@%!/|]
00:21:57 32302 user in "^[.] : ^.*[@%!/|]"? no (end of list)
00:21:57 32302 deny: condition test failed
00:21:57 32302 processing "deny"
00:21:57 32302 check domains = !+local_domains
00:21:57 32302 expanding: SELECT `domain` FROM `domain` WHERE `domain`='${domain}' AND `active`='1'
00:21:57 32302 result: SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'
00:21:57 32302 search_open: mysql "NULL"
00:21:57 32302 cached open
00:21:57 32302 search_find: file="NULL"
00:21:57 32302 key="SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'" partial=-1 affix=NULL starflags=0
00:21:57 32302 LRU list:
00:21:57 32302 internal_search_find: file="NULL"
00:21:57 32302 type=mysql key="SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'"
00:21:57 32302 cached data used for lookup of SELECT `domain` FROM `domain` WHERE `domain`='my_host.ru' AND `active`='1'
00:21:57 32302 lookup yielded: my_host.ru
00:21:57 32302 expanding: ${lookup mysql{SELECT `domain` FROM `domain` WHERE `domain`='${domain}' AND `active`='1'}}
00:21:57 32302 result: my_host.ru
00:21:57 32302 my_host.ru in "my_host.ru"? yes (matched "my_host.ru")
00:21:57 32302 my_host.ru in "!+local_domains"? no (matched "!+local_domains")
00:21:57 32302 deny: condition test failed
00:21:57 32302 processing "accept"
00:21:57 32302 check hosts = +relay_from_hosts
;; res_nquerydomain(localhost, ru, 1, 28)
;; res_query(localhost.ru, 1, 28)
;; res_nmkquery(QUERY, localhost.ru, IN, AAAA)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55704
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; localhost.ru, type = AAAA, class = IN
;; Querying server (# 1) address = х.х.х.х
;; new DG socket
;; timeout
;; Querying server (# 2) address = y.y.y.y
;; new DG socket
;; timeout
;; Querying server (# 1) address = х.х.х.х
;; timeout
;; Querying server (# 2) address = y.y.y.y
;; timeout
;; res_query: send error
res_nsearch failed (-1)
00:22:19 32302 gethostbyname2(af=inet6) returned 2 (TRY_AGAIN)
00:22:19 32302 gethostbyname2 looked up these IP addresses:
00:22:19 32302 name=localhost address=127.0.0.1
00:22:19 32302 host in "localhost:127.0.0.0/8:x.x.x.x"? yes (matched "localhost")
00:22:19 32302 host in "+relay_from_hosts"? yes (matched "+relay_from_hosts")
00:22:19 32302 check control = submission
00:22:19 32302 accept: condition test succeeded
00:22:19 32302 SMTP>> 250 Accepted
00:22:19 32302 SMTP<< RSET
00:22:19 32302 SMTP>> 250 Reset OK
00:22:19 32302 SMTP>> 421 my_host.ru lost input connection
00:22:19 32302 LOG: smtp_connection MAIN
00:22:19 32302 SMTP connection from (www.my_host.ru) [127.0.0.1] I=[127.0.0.1]:25 lost (error: Connection reset by peer)
00:22:19 32302 search_tidyup called
00:22:19 32302 close MYSQL connection: localhost/*****/****
00:22:19 32300 child 32302 ended: status=0x100
00:22:19 32300 0 SMTP accept processes now running
00:22:19 32300 Listening...
Код: Выделить всё
primary_hostname = my_host.ru
hide mysql_servers = **************
domainlist local_domains = ${lookup mysql{SELECT `domain` \
FROM `domain` WHERE \
`domain`='${domain}' AND \
`active`='1'}}
domainlist relay_to_domains =${lookup mysql{SELECT `domain` \
FROM `domain` WHERE \
`domain`='${domain}' AND \
`active`='1'}}
hostlist relay_from_hosts = localhost:127.0.0.0/8:х.х.х.х:y.y.y.y
acl_smtp_connect = acl_check_connect
acl_smtp_rcpt = acl_check_rcpt
acl_smtp_data = acl_check_data
qualify_domain = my_host.ru
qualify_recipient = my_host.ru
exim_user = mailnull
exim_group = mail
never_users = root
host_lookup = !127.0.0.1 : !localhost : !х.х.х.х : !y.y.y.y : *
#rfc1413_hosts = *
rfc1413_query_timeout = 0s
ignore_bounce_errors_after = 1h
timeout_frozen_after = 2d
freeze_tell = error@my_host.ru
split_spool_directory = true
auto_thaw = 1h
smtp_banner = "$primary_hostname, ESMTP EXIM $version_number"
smtp_accept_max = 50
smtp_accept_max_per_connection = 25
smtp_accept_max_per_host = 20
remote_max_parallel = 15
helo_allow_chars = _
smtp_enforce_sync = false
log_selector = \
+all_parents \
+connection_reject \
+incoming_interface \
+lost_incoming_connection \
+received_sender \
+received_recipients \
+smtp_confirmation \
+smtp_syntax_error \
+smtp_protocol_error \
-queue_run
syslog_timestamp = no
begin acl
acl_check_connect:
accept hosts = 127.0.0.1:localhost:х.х.х.х:my_host.ru
control = no_enforce_sync
accept
acl_check_rcpt:
accept hosts = :
deny message = Restricted characters in address
domains = +local_domains
local_parts = ^[.] : ^.*[@%!/|]
deny message = Restricted characters in address
domains = !+local_domains
local_parts = ^[./|] : ^.*[@%!] : ^.*/\\.\\./
accept hosts = +relay_from_hosts
control = submission
accept authenticated = *
# control = submission
require message = relay not permitted
domains = +local_domains : +relay_to_domains
require verify = recipient
accept
acl_check_data:
accept
begin routers
dnslookup:
driver = dnslookup
domains = ! +local_domains
transport = remote_smtp
ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
no_more
mysqluser:
driver = accept
condition = ${if eq{}{${lookup mysql{SELECT `maildir` FROM `mailbox` \
WHERE `username`='${quote_mysql:$local_part@$domain}'}}}{no}{yes}}
transport = mysql_delivery
system_aliases:
## driver = redirect
## allow_fail
## allow_defer
## data = ${lookup{$local_part}lsearch{/etc/aliases}}
## user = mailnull
## group = mail
## file_transport = address_file
## pipe_transport = address_pipe
driver = redirect
allow_fail
allow_defer
data = ${lookup mysql{SELECT `goto` FROM `alias` WHERE \
`address`='${quote_mysql:$local_part@$domain}' OR \
`address`='${quote_mysql:@$domain}'}}
userforward:
driver = redirect
check_local_user
# local_part_suffix = +* : -*
# local_part_suffix_optional
file = $home/.forward
# allow_filter
no_verify
no_expn
check_ancestor
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply
condition = ${if exists{$home/.forward} {yes} {no} }
localuser:
driver = accept
check_local_user
# local_part_suffix = +* : -*
# local_part_suffix_optional
transport = local_delivery
cannot_route_message = Unknown user
begin transports
remote_smtp:
driver = smtp
mysql_delivery:
driver = appendfile
check_string = ""
create_directory
delivery_date_add
directory = ${lookup mysql{SELECT CONCAT('/var/mail/exim/', `maildir`) \
FROM `mailbox` WHERE `username`='${local_part}@${domain}'}}
directory_mode = 770
envelope_to_add
group = mail
maildir_format
maildir_tag = ,S=$message_size
message_prefix = ""
message_suffix = ""
mode = 0600
address_pipe:
driver = pipe
return_output
address_file:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add
address_reply:
driver = autoreply
begin retry
* * F,2h,15m; G,16h,1h,1.5; F,4d,6h
begin rewrite
begin authenticators
auth_plain:
driver = plaintext
public_name = PLAIN
server_condition = ${lookup mysql{SELECT `username` FROM \
`mailbox` WHERE `username` = \
'${quote_mysql:$1}' AND `password` = \
'${quote_mysql:$2}'}{yes}{no}}
server_prompts = :
server_set_id = $2
auth_login:
driver = plaintext
public_name = LOGIN
server_condition = ${lookup mysql{SELECT `username` FROM \
`mailbox` WHERE `username` = \
'${quote_mysql:$1}' AND `password` = \
'${quote_mysql:$2}'}{yes}{no}}
server_prompts = Username:: : Password::
server_set_id = $1
auth_cram_md5:
driver = cram_md5
public_name = CRAM-MD5
server_secret = ${lookup mysql{SELECT `password` FROM \
`mailbox` WHERE `username` \
= '${quote_mysql:$1}'}{$value}fail}
server_set_id = $1