J
J
jidckii2016-01-28 12:52:11
linux
jidckii, 2016-01-28 12:52:11

How to set up Postfix Relay?

Hello.
There is a server on which postfix is ​​already configured in some way and it is impossible to break what is impossible.
In addition to this, I have a task to set up a relay of incoming emails for 1 domain.
That is, I need to accept everything for the domain.net zone and forward it to mx.domain.net
if the latter is unavailable, wait a couple of days, and if that does not rise, then return the letters.
Here is the current config:

[email protected]:/etc/postfix# cat main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myorigin = /etc/mailname
myhostname = host.netangels.ru
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 20485760
recipient_delimiter = +
inet_interfaces = all

###
transport_maps = hash:/etc/postfix/transport

virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = hash:/etc/postfix/virtual_domains
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailboxes
virtual_alias_maps = hash:/etc/postfix/virtual_aliases
virtual_minimum_uid = 100
virtual_uid_maps = static:998
virtual_gid_maps = static:65534

smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_type = dovecot
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_path = private/auth

maximal_queue_lifetime = 2d
bounce_queue_lifetime = 2d

disable_vrfy_command = yes

smtpd_client_message_rate_limit = 32
#smtpd_client_connection_rate_limit = 8
smtpd_client_recipient_rate_limit = 10
smtpd_helo_required = yes
smtp_helo_timeout = 60s
smtpd_delay_reject = no
smtpd_soft_error_limit = 1
smtpd_hard_error_limit = 1
smtpd_error_sleep_time = 0

header_checks = regexp:/etc/postfix/header_checks

# milter greylist
smtpd_milters = unix:greylist/milter-greylist.sock

#HELO/EHLO
smtpd_helo_restrictions =
    permit_mynetworks,
    check_helo_access regexp:/etc/postfix/helo_access,
    #reject_non_fqdn_helo_hostname,
    permit

# sender ip address
smtpd_client_restrictions =
    permit_mynetworks,
    #check_client_access hash:/etc/postfix/access,
    #reject_unknown_reverse_client_hostname

# MAIL FROM
smtpd_sender_restrictions =
    permit_mynetworks,
    reject_non_fqdn_sender,
    reject_unknown_sender_domain

#RCPT TO
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    check_client_access hash:/etc/postfix/access,
    reject_non_fqdn_helo_hostname,
    reject_unknown_reverse_client_hostname,
    reject_unauth_destination,
    reject_unlisted_recipient

I don't quite understand how to implement this.
in fact, I need to add in time
mydestination = $myhostname, localhost
mydestination = $myhostname, localhost, domain.net
and in
relayhost =
add:
relayhost = mx.domain.net
Is that all, or did I somehow misunderstand the documentation?
And it also turns out that in this case, all mail will be relayed in general, not only for the domain I need.
How to implement the desired functionality correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2016-01-28
@mblp

yes, relayhost = mx.domain.netall mail will go there.
look at yours:
transport_maps = hash:/etc/postfix/transport
that is, add transport for domain.net
there, and in mydestination, of course, too.

M
Maxim Kovalenko, 2016-01-28
@maxxx_kovalenko

You do not need to set up a relay, but transport.
Check if there is a line in main.cf
In /etc/postfix/transport

domain.net smtp:[mx.domain.net]
.domain.net smtp:[mx.domain.net]

Apply changes:
/usr/sbin/postmap /etc/postfix/transport

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question