1

On my home Ubuntu box, postfix is configured to relay all outgoing email to outgoing.verizon.net. Unfortunately this includes local user-to-user email (e.g., from local cron jobs to me, or from me to myself) which should not need to travel off-machine. Is there a way to tweak my configuration (below) so local email is delivered without leaving my machine?

Note: I don't run a mail server (on port 25) but rather run fetchmail every five minutes to download from an IMAP server.

main.cf:

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mycomputer.example.com
masquerade_domains = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost.localdomain, localhost
relayhost = [outgoing.verizon.net]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtp_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtpd_sasl_auth_enable = no
0

Postfix will only relay non-local mails to the host specified in the relayhost. To consider a domain local; the domain has to be listed under mydestination parameter. So listing example.com under mydestination should help you to fix this issue.

#/etc/postfix/main.cf
#...
mydestination = $myhostname, localhost.localdomain, localhost, example.com
#...

Ref: Postfix docs

relayhost (default: empty)

The next-hop destination of non-local mail; overrides non-local domains in 
recipient addresses. This information is overruled with relay_transport, 
sender_dependent_default_transport_maps, default_transport, 
sender_dependent_relayhost_maps and with the transport(5) table. 
4
  • Hmm... With my posted configuration, username@localhost gets forwarded to the relayhost. If your analysis is correct, shouldn't username@localhost be handled entirely locally because "localhost" is listed in mydestination? – DanB Mar 29 '14 at 13:48
  • Can u post the maillog generated by postfix for such a mail? – clement Mar 29 '14 at 14:19
  • Ah, I was incorrect. username@localhost indeed gets delivered locally. However, mail to just "username" (e.g., "echo foo | /usr/bin/mail username") gets delivered as if I had emailed username@blazemonger.com. – DanB Mar 29 '14 at 14:45
  • Then I guess ur myorigin has blazemonger.com. Add blazemonger.com to mydestination to treat it local. – clement Mar 29 '14 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.