V
V
Vyacheslav Kordienko2016-09-21 12:57:24
Mail server
Vyacheslav Kordienko, 2016-09-21 12:57:24

Mail server (Postfix + Dovecot + Postgrey)?

Hi all!
I can’t figure out the server settings in any way
There is a current working server, I want to transfer everything to a new one
- Letters are stored in folders, of this type (mail to two domain names):
/var/www/administrator/data/email/site1/
/var/ www/administrator/data/email/site2/
1. Transferred using rsync to the same folder, created the same user "administrator"
2. Also transferred the dovecot and postfix
config files the main.cf file

spoiler
soft_bounce = no  
queue_directory = /var/spool/postfix  
daemon_directory = /usr/libexec/postfix  
command_directory = /usr/sbin
data_directory = /var/lib/postfix
mail_owner = postfix  
default_privs = nobody  
inet_interfaces = all 
inet_protocols = ipv4 
myhostname = site1.ru  
mydomain = localdomain  
myorigin = site1.ru
mydestination = $myhostname,localhost.$myhostname,localhost  
local_recipient_maps = proxy:unix:passwd.byname $alias_maps  
unknown_local_recipient_reject_code = 550  
mynetworks = айпи.офиса.1.11/32  
relay_domains =  
alias_maps = hash:/etc/aliases  
alias_database = hash:/etc/aliases  
#mail_spool_directory = /var/mail  
smtpd_banner = $myhostname ESMTP  
debug_peer_level = 2  
debug_peer_list = 127.0.0.1  
debugger_command =   
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin  
    xxgdb $daemon_directory/$process_name $process_id & sleep 5   
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix  
setgid_group = postdrop  
html_directory = no  
manpage_directory = /usr/local/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
config_directory = /etc/postfix


mailbox_size_limit = 0 
virtual_alias_domains = /etc/mail/local-host-names
virtual_alias_maps = hash:/etc/mail/virtusertable
smtp_generic_maps = hash:/etc/mail/generic
broken_sasl_auth_clients = no

smtpd_tls_auth_only = no
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
tls_random_source = dev:/dev/urandom

#smtpd_tls_key_file = /etc/postfix/sslsmtpd.key
#smtpd_tls_cert_file = /etc/postfix/sslsmtpd.crt

smtpd_tls_CAfile = etc/postfix/postfix.pem
smtp_tls_CAfile = etc/postfix/postfix.pem
smtpd_tls_key_file = etc/postfix/postfix.pem
smtpd_tls_cert_file = etc/postfix/postfix.pem
smtpd_tls_received_header = yes
smtpd_tls_loglevel = 1
smtpd_sender_restrictions = permit_sasl_authenticated, check_sender_access hash:/etc/mail/access
smtpd_client_restrictions = permit_sasl_authenticated, check_client_access hash:/etc/mail/access
smtpd_recipient_restrictions = permit_sasl_authenticated, check_sender_access hash:/etc/mail/access, check_client_access hash:/etc/mail/access, check_recipient_access hash:/etc/mail/access, permit_mynetworks, reject_unauth_destination, reject_unlisted_recipient, reject_unverified_recipient, reject_unknown_client, check_policy_service inet:127.0.0.1:60000

smtpd_reject_unlisted_sender = yes
smtpd_milters = inet:127.0.0.1:8891
non_smtpd_milters = inet:127.0.0.1:8891
message_size_limit = 71200000


dovecot.conf file
spoiler
## Dovecot configuration file

# If you're in a hurry, see http://wiki.dovecot.org/QuickConfiguration
# --sysconfdir=/etc --localstatedir=/var
# Protocols we want to be serving.
#protocols = imap pop3 lmtp
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
# If you want to specify non-default ports or anything more complex,
# edit conf.d/master.conf.
#listen = *, ::
#base_dir = /var/run/dovecot/
#login_greeting = Dovecot ready.
#login_trusted_networks =
#login_access_sockets = 
#verbose_proctitle = no
#shutdown_clients = yes
#doveadm_worker_count = 0
#doveadm_socket_path = doveadm-server
# "proxy::<name>".

dict {
  #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
  #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
}

!include conf.d/*.conf
#!include_try /etc/dovecot/local.conf
listen = *

# Существует несколько специальных переменных, которые вы можете использовать:
#   %u - имя пользователя
#   %n - пользовательская часть в [email protected], то же самое что и %u
#   если не задана доменная часть
#   %d - доменая часть в [email protected], пустая, если не указан домен
#   %h - домашняя директория
# Смотрите doc/variables.txt для полного списка переменных.
# Некоторые примеры:
#   mail_location = maildir:~/Maildir
#   mail_location = mbox:~/mail:INBOX=/var/mail/%u
#   mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
mail_location = maildir:/var/www/administrator/data/email/%d/%n

# Настройка пространства имен почтового ящика
# Указывает разделитель в пути, префикс для всех папок, и наличие отдельной папки Входящие
namespace private {
  separator = /
  prefix = [TESTMAIL]/
  inbox = yes
}


The dovecot.passwd file has entries like this:
spoiler
[email protected]:{CRAM-MD5}61f2a1axc3345a2f7788c9741b857834xxc1237597dfcae13a8e1443b843206a4:648:502::/var/www/administrator/data/email/site1/mananger:::maildir:/var/www/administrator/data/email/site1.ru/manager/.maildir


file /etc/aliases
spoiler
# Basic system aliases -- these MUST be present.
mailer-daemon:	postmaster
postmaster:	root
# General redirections for pseudo accounts.
bin:		root
daemon:		root
adm:		root
lp:		root
sync:		root
shutdown:	root
halt:		root
mail:		root
news:		root
uucp:		root
operator:	root
games:		root
gopher:		root
ftp:		root
nobody:		root
radiusd:	root
nut:		root
dbus:		root
vcsa:		root
canna:		root
wnn:		root
rpm:		root
nscd:		root
pcap:		root
apache:		root
webalizer:	root
dovecot:	root
fax:		root
quagga:		root
radvd:		root
pvm:		root
amanda:		root
privoxy:	root
ident:		root
named:		root
xfs:		root
gdm:		root
mailnull:	root
postgres:	root
sshd:		root
smmsp:		root
postfix:	root
netdump:	root
ldap:		root
squid:		root
ntp:		root
mysql:		root
desktop:	root
rpcuser:	root
rpc:		root
nfsnobody:	root

ingres:		root
system:		root
toor:		root
manager:	root
dumper:		root
abuse:		root

newsadm:	news
newsadmin:	news
usenet:		news
ftpadm:		ftp
ftpadmin:	ftp
ftp-adm:	ftp
ftp-admin:	ftp
www:		webmaster
webmaster:	root
noc:		root
security:	root
hostmaster:	root
info:		postmaster
marketing:	postmaster
sales:		postmaster
support:	postmaster

# trap decode to catch security attacks
decode:		root
virtuser_503:	\virtuser_503
virtuser_504:	\virtuser_504
virtuser_505:	\virtuser_505,[email protected]
virtuser_506:	\virtuser_506
virtuser_507:	\virtuser_507
virtuser_508:	\virtuser_508
virtuser_509:	\virtuser_509
virtuser_510:	\virtuser_510
virtuser_511:	\virtuser_511
И ТАК ДАЛЕЕ
 # Person who should get root's mail
#root:		marc


In the folder /etc/mail/ the files are "access, access.db, domainips, generic, generic.db, local-host-names, virtusertable, virtusertable.db".
file /etc/mail/virtusertable like this.
spoiler
[email protected]	virtuser_503
[email protected]	virtuser_504
[email protected]	virtuser_502
[email protected]	virtuser_508


Testing IMAP login
spoiler
[[email protected] ~]# telnet 127.0.0.1 143
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN AUTH=DIGEST-MD5 AUTH=CRAM-MD5] Dovecot ready.
1 LOGIN [email protected] *пароль*
1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in
1 SELECT INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded $MDNSent Junk NonJunk)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft $Forwarded $MDNSent Junk NonJunk \*)] Flags permitted.
* 3543 EXISTS
* 0 RECENT
* OK [UNSEEN 19] First unseen.
* OK [UIDVALIDITY 1411968184] UIDs valid
* OK [UIDNEXT 7968] Predicted next UID
* OK [HIGHESTMODSEQ 2685] Highest
1 OK [READ-WRITE] Select completed.


Testing SMTP without authorization
spoiler
[[email protected] ~]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 site1.ru ESMTP
helo darling
250 site1.ru
MAIL FROM: [email protected]
451 4.7.1 Service unavailable - try again later


I can't figure out what I'm doing wrong.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
V
Vyacheslav Kordienko, 2016-09-21
@AmonTobin

master.cf file

spoiler
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd
#submission inet n       -       n       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
#628      inet  n       -       n       -       -       qmqpd
pickup    fifo  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       n       -       -       smtp
  -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop  unix  -       n       n       -       -       pipe
#  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# The Cyrus deliver program has changed incompatibly, multiple times.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
#uucp      unix  -       n       n       -       -       pipe
#  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# ====================================================================
#
# Other external delivery methods.
#
#ifmail    unix  -       n       n       -       -       pipe
#  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
#
#bsmtp     unix  -       n       n       -       -       pipe
#  flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
#
#scalemail-backend unix -       n       n       -       2       pipe
#  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store
#  ${nexthop} ${user} ${extension}
#
#mailman   unix  -       n       n       -       -       pipe
#  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
#  ${nexthop} ${user}
#smtps inet n       -       n       -       -       smtpd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question