Search code examples
hostingexchange-serverpleskpostfix-mta

Configure Mailserver manual with Plesk Host


We do some easy hosting for our clients. One of them is using a self-hosted Mail Exchange server that needs an SMTP on our server. So we have the MX DNS entries pointing to their server, and postfix running with one mailbox for sending Emails.

Now the first problem is, that Plesk thinks it can deliver Mails local when sending an eMail from Client x to the Client we're talking about. Which fails, because the mailbox doesn't exist here and Plesk does not ask for the MX entry.

Second: We'd want to configure postfix to run as an Backup MX for this client.

Is there any way to configure postfix per abonnement manually, having the mail service disabled in Plesk so that Mails sent locally will be delivered? Do you have other ideas? We're thinking about using another server for cases like this. But running Plesk on that other server would cost us more licences because of multiple domains (upcoming).

We are running on Ubuntu with Plesk Host.


Solution

    1. Add a MX Record with higher priority to DNS-Settings.
    2. Edit /etc/postfix/main.cf and add the Domain to relay_domains. Add empty relay_recipient_maps parameter
    relay_domains = $mydestination, domain.com
    relay_recipient_maps =
    
    1. Make a backup of virtual_domains.db
    cp /var/spool/postfix/plesk/virtual_domains.db /var/spool/postfix/plesk/virtual_domains.db.backup
    
    1. Make the database editable
    postmap -s /var/spool/postfix/plesk/virtual_domains > /var/spool/postfix/plesk/virtual_domains
    
    1. Edit the file and remove the line example.com
    vi /var/spool/postfix/plesk/virtual_domains
    
    1. Recreate the virtual_domains.db file with the following command and remove the editable virtual_domains file
    postmap /var/spool/postfix/plesk/virtual_domains
    rm /var/spool/postfix/plesk/virtual_domains
    
    1. Restart Postifx
    service postfix restart
    
    1. Test it by checking the postqueue and maillog
    postqueue -p
    // and
    tail -f /var/log/maillog
    

    Warning: virtual_domains.db might get overwritten when changeing other stuff via plesk