0

I'm facing an issue with my Postfix setup where it should be saving all emails locally using a custom script, but instead, it attempts to forward outgoing emails, leading to "Relay access denied" errors. Incoming emails are processed and saved correctly.

Setup Details:

  • Postfix is configured to use a custom transport called saveemail for saving emails.
  • The system processes incoming emails correctly and triggers the saveemail script.
  • For outgoing emails, instead of saving, Postfix attempts to forward them, which is not the desired behavior.

Relevant Configuration:

mydestination = $myhostname, localhost.$mydomain, localhost

Postfix Logs:

May 13 13:42:16 mail-archive postfix/smtpd[74224]: connect from esg-app03-op1.aba.com[172.25.46.67]
May 13 13:42:16 mail-archive postfix/smtpd[74224]: D64378899D7: client=esg-app03-op1.aba.com[172.25.46.67]
May 13 13:42:16 mail-archive postfix/qmgr[66092]: D64378899D7: from=<[email protected]>, size=28112, nrcpt=1 (queue active)
May 13 13:42:16 mail-archive postfix/local[82557]: D64378899D7: to=<[email protected]>, orig_to=<[email protected]>, relay=local, delay=0.04, delays=0.03/0/0/0.01, dsn=2.0.0, status=sent (delivered to command: /usr/local/bin/save_email.sh)
May 13 13:42:16 mail-archive postfix/qmgr[66092]: D64378899D7: removed
May 13 13:42:19 mail-archive postfix/smtpd[74251]: connect from esg-app04-op2.aba.com[172.20.42.68]
May 13 13:42:19 mail-archive postfix/smtpd[74251]: NOQUEUE: reject: RCPT from esg-app04-op2.aba.com[172.20.42.68]: 454 4.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail04.abashop.com>
May 13 13:42:21 mail-archive postfix/smtpd[74224]: disconnect from esg-app03-op1.aba.com[172.25.46.67]

I'm looking for guidance on how to adjust the Postfix configuration so that it saves outgoing emails locally, just like it does with incoming ones. Any help would be greatly appreciated!

[root@mail-archive ~]# postconf -n  
command_directory = /usr/sbin  
config_directory = /etc/postfix  
daemon_directory = /usr/libexec/postfix  
data_directory = /var/lib/postfix  
debug_peer_level = 3  
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd   $daemon_directory/$process_name $process_id & sleep 5  
default_transport = saveemail  
html_directory = no  
inet_interfaces = all  
inet_protocols = ipv4  
local_recipient_maps =  
mail_owner = postfix  
mailq_path = /usr/bin/mailq.postfix  
manpage_directory = /usr/share/man  
mydestination = $myhostname, localhost.$mydomain, localhost  
mydomain = abashop.com  
myhostname = mail-archive.aba.com  
mynetworks = 172.20.20.86/32, 127.0.0.0/8  
newaliases_path = /usr/bin/newaliases.postfix  
queue_directory = /var/spool/postfix  
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES  
sample_directory = /usr/share/doc/postfix-2.10.1/samples  
sendmail_path = /usr/sbin/sendmail.postfix  
setgid_group = postdrop  
unknown_local_recipient_reject_code = 550  
virtual_alias_domains = abashop.com  
virtual_alias_maps = hash:/etc/postfix/virtual  
[root@mail-archive ~]# postconf -M  
smtp       inet  n       -       n       -       -       smtpd  
smtpd      pass  -       -       n       -       -       smtpd  
submission inet  n       -       n       -       -       smtpd -o   syslog_name=postfix/submission -o smtpd_tls_wrappermode=no -o   smtpd_tls_security_level=may -o smtpd_tls_auth_only=no -o   milter_macro_daemon_name=ORIGINATING  
smtps      inet  n       -       n       -       -       smtpd -o   syslog_name=postfix/smtps -o milter_macro_daemon_name=ORIGINATING  
pickup     unix  n       -       n       60      1       pickup  
cleanup    unix  n       -       n       -       0       cleanup  
qmgr       unix  n       -       n       300     1       qmgr  
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  
relay      unix  -       -       n       -       -       smtp  
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  
saveemail  unix  -       n       n       -       -       pipe flags=DRhu   user=postfix argv=/usr/local/bin/save_email.sh ${sender} ${size}   ${recipient}
10
  • Relevant configuration should include the full output of postconf -M and postconf -n (as in the tag description). You may obfuscate your public names and IPs, but don't change anything else. Commented May 13 at 8:02
  • Added postconf -M and postconf -n
    – Chika228
    Commented May 13 at 8:13
  • Please format code and log messages by using the {} button in the editor. This will make the post more readable.
    – vidarlo
    Commented May 13 at 8:25
  • Ok, after formatting I was finally able to read logs properly. Where do you see it relays mail instead of saving? It is clearly seen in lines 1-2-3 that it delivers to command and removes from the queue. Log lines 4-5 are about some other message, probably, it was DSN requested by the sender. Commented May 13 at 8:39
  • edited postfix logs
    – Chika228
    Commented May 13 at 8:54

0

You must log in to answer this question.

Browse other questions tagged .