Postfix Relay - Configuration without Auth

voicemail
Tags: #<Tag:0x00007f702998b250>

(Dpbx71) #1

I need to setup postfix to relay using an SMTP server. There is no AUTH LOGIN so I do not need to setup the usual sasl_passwd file.

Telnet Successful
I can successfully use telnet to send an email from the SMTP server.
[1] telnet relayserverdomainFQDN 25
[2] EHLO
[3] MAIL FROM:voicemail@relayserverdomain.com
[4] RCPT TO:enduser@domain.com
[5] DATA – add body content

Postfix Setup Not Successfull
[1] Add this value to /etc/postfix/main.cf
relayhost = [relayserverdomainFQDN]:25
[2] postfix reload
[3] sudo -u asterisk mail -s TestEmail enduser@domain.com
Result: No relay. Email sent directly from server.


(Andrew) #2

You may need to set the mynetworks variable in main.cf. So assuming your internal network is 192.168.1.0/24:

mynetworks = 127.0.0.0/8 192.168.1.0/24

(Dpbx71) #3

No dice on the modified values:

relayhost = [relayaddress]:25
mynetworks = 127.0.0.0/8 10.0.0.0/8


(Andrew) #4

May also need to specify:

smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

Make sure to restart postfix after the changes as well.


(Dpbx71) #5

Went ahead and added that line as well as a postfix reload and service postfix restart. No luck.


(Andrew) #6

Try adding check_recipient_access hash:/etc/postfix/access.recipients in the smtpd_recipient_restrictions variable. So:

smtpd_recipient_restrictions = 
   permit_sasl_authenticated,
   permit_mynetworks,
   reject_unauth_destination,
   check_recipient_access hash:/etc/postfix/access.recipients

then create /etc/postfix/access.recipients and in it put all recipient domains you want to allow

domain.com OK

Then run postmap /etc/postfix/access.recipients and restart postfix. If it’s not that then it’s past my postfix knowledge, sorry :frowning:


(Dpbx71) #7

While it didn’t, I do appreciate all of your help! It was a valiant effort. If I can figure this out, I’ll share the solution.


(Dpbx71) #8

Solution

[1] Turns out the relay was actually working (I didn’t have access to the SMTP server itself), but it kept the source from address.

[2] Edit generic file
Add: sourcefrom desiredfrom
i.e., freepbx.local relayfromaddress@domain.com

[3] Add to main.cf
smtp_generic_maps = hash:/etc/postfix/generic

[4] Run postmap against generic

[5] reload postmap; restart postmap; run test email


(Andrew) #9

Lol I literally offered this solution to someone recently here. Good work figuring it out!