Postfix – Determining Default Relay Host When Using Multiple Relay Hosts

centos7postfixsendgrid

I know that this might seems to be a lame question but hey , let me give it a try …

Hi, I am hosting different domains and trying to configure postfix to send mails through sendgrid for certain domains with different authentication, and the rest of the remaining domains to use postfix's local settings to send mail normally i.e using my default relay host, here is what I managed to compile from their website and added my settings

/etc/postfix/main.cf:
    smtp_sender_dependent_authentication = yes
    sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    relayhost = my.default.relay.com

/etc/postfix/sasl_passwd:
    # Per-sender authentication; see also /etc/postfix/sender_relay.
    user1@example0.com                  apikey:thatAPIkeyfromSendGrid
    @domain1.example1.com               username1:password1
    @domain2.example.com                username2:password2
    # Login information for the default relayhost(which is?)
    [my.default.relay.com]              username:password

/etc/postfix/sender_relay:
    # Per-sender provider; see also /etc/postfix/sasl_passwd.
    @domain1.example.com               [sendgrid.net]:submission
    @domain2.example.com               [sendgrid.net]:submission

Now for some reason , I cannot figure it out my default relay host?
I tried

relay_host = 

and

relay_host = $domain

also

relay_host = [my.default.relay.com]

In the end I still get mail for [my.default.relay.com] loops back to myself, off course I did the postmaps of sender_relay,sasl_passwd and change them to chmod 600

Can you help on finding out what my default relay host is? Or a possible way to solve my problem?

PS: I am not into Open Relay though

Best Answer

The configuration parameter is relayhost, not "relay_host". You are asking what is your default relayhost and you have got an answer on how to figure it out. I think you're actually trying to ask what this should be.

The relayhost can be empty as it is by default. You don't need to have a relayhost unless your connectivity to the Internet on SMTP port 25 is limited. Postfix will by default query DNS for a mail exchanger MX record of the recipient domain and communicate directly with the receiving message transfer agent (MTA).

Related Topic