0

I have a mail server which has the primary MX record and this mail server handles all the mail inboxes and mail in and out of the mail boxes.

I setup a second mail server which doesn't have an MX record but is only acting as a server to send out mail only, no incoming mail is accepted. This second server is just to send mail out from a website that is load balanced across a few nodes and only the web server nodes have access to send mail out from this second mail server.

All the above is working great, the issue I have now is that when someone fills out a contact form on the website I send a mail to the user that submitted the form and I also send the contents of the form to a info email so the site is example.com and I send one of the mails to info@example.com, the problem here is that the email to info@example.com is handled locally on the server and I want it to be sent out externally from the second mail server like any other mail.

The mail server is mail2.example.com.

Hope this makes sense.

main.cf

myhostname = mail2.example.com
mydomain = example.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
local_recipient_maps = unix:passwd.byname $alias_maps

# Custom changes
message_size_limit = 10485760
mailbox_size_limit = 0
always_add_missing_headers = yes

# Server
smtpd_tls_loglevel = 1
smtpd_tls_security_level = may
smtpd_tls_cert_file = /etc/letsencrypt/live/mail2.example.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail2.example.com/privkey.pem
smtpd_tls_CApath = /etc/letsencrypt/live/mail2.example.com
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_protocols = !SSLv2,!SSLv3
smtpd_tls_mandatory_ciphers = high
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_tls_eecdh_grade = strong

# Client
smtp_tls_loglevel = 1
smtp_tls_security_level = may
smtp_tls_cert_file = /etc/letsencrypt/live/mail2.example.com/fullchain.pem
smtp_tls_key_file = /etc/letsencrypt/live/mail2.example.com/privkey.pem
smtp_tls_CApath = /etc/letsencrypt/live/mail2.example.com
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_mandatory_exclude_ciphers = MD5 , DES, ADH, RC4, SRP, 3DES, eNULL
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_protocols = !SSLv2,!SSLv3
smtp_tls_mandatory_ciphers = high
llanato
  • 211
  • 2
  • 4
  • 12
  • Please check `mydestination` and include its setting. Are you using virtual folders? Check `local_recipient_maps` and `virtual_mailbox_domains`. Also try setting `myhostname` to be different than your incoming mail server. – Chloe Jun 05 '17 at 16:05
  • Also check https://serverfault.com/questions/137591/postifx-disable-local-delivery?rq=1 – Chloe Jun 05 '17 at 16:10

2 Answers2

1

Unlike mc0e understood this question, it seems like you are not setting up a secondary MX. Instead, you want the server (mail2) to treat example.com just like any other domain.

The solution for that is much more easy: just remove $mydomain (i.e. example.com) from your mydestination, resulting:

mydestination = $myhostname, localhost.$mydomain, localhost

Which is actually, after replacing the variables, same as there was:

mydestination = mail2.example.com, localhost.example.com, localhost

This is also the default for mydestination, so removing the whole line has the same effect.

Esa Jokinen
  • 46,944
  • 3
  • 83
  • 129
0

You are missing all of the relevant stuff for the MX relay function, so rather than go through all the specifics, I'll refer you to the authoritative source: Configuring Postfix as primary or backup MX host for a remote site.

mc0e
  • 5,866
  • 18
  • 31