Make postfix send email externally for virtual domains on Plesk

Standard set-up - Plesk running various websites, but using external email services ie. the MX records are Gmail or whatever.

With this set up and the default Postfix settings, SMTP will try to deliver email addressed to Plesk virtual domains to locally configured email accounts, in other words only to those set up in Plesk. If you're not using your webserver to store email, then trying to send via you'll get the following error in /var/log/mail.log :

SMTP Error: The following recipients failed: sales@somewebsite.com: <sales@somewebsite.com>: Recipient address rejected: User unknown in virtual mailbox table

Note: I had to "ln -s /usr/local/psa/var/log/maillog mail.log" to get email logging into the /var/log/mail.log file.

To get the external routing working :

set hostname

hostname my_web_server.com

Edit /etc/postfix/main.cf

Remove $mydomain from mydestination variable.

# was mydestination = localhost.$mydomain, localhost, localhost.localdomain
mydestination = localhost, localhost.localdomain, my_web_server.com

Comment out the line :

#virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains

Restart postfix

/etc/init.d/postfix reload

Postfix mail service will now deliver email externally (ie. use MX records) for virtual domains.

UPDATE:

You can also just comment out these 3 lines from /etc/postfix/main.cf to get Postfix to deliver mail externally only.

#virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
#virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual`
#virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox`

There may be more than one virtual_mailbox_domains line as Plesk likes to add copies of it in there!
Ref: https://serverfault.com/questions/137591/postifx-disable-local-delivery

One thought on “Make postfix send email externally for virtual domains on Plesk

  1. Pingback: education

Leave a Reply