I am configuring a hosting + mail setup. I have one server for hosting websites, and one for the smtp/imap/dovecat server.
As far as I researched, the only reasonable way to allow my customers to have their mailboxes without creating users in the server for them was using virtual boxes.
So, I have configured my "domains" table as the virtual box source for postfix. It is working fine, except for one scenario.
I have one domain hosted with us that is using Google Apps. So, this domain is in our "domain" table, because of DNS entries, and it is being identified as a virtual box for postfix. When I try to write an e-mail to this user from another virtual box in the server, postfix tries to find the recipient in the local server, and throws the following error:
Dec 26 17:45:14 mail postfix/smtpd[4833]: NOQUEUE: reject: RCPT from localhost[::1]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual mailbox table; I checked in postfix documentation that this is by design; every virtual box is assumed to be hosted in the local server. But then, I would be required to create actual users in the server for each hosted user, which sounds really bad, and it is not what hosting panels usually do.
I thought of creating a separated table to store the virtual boxes, so I would only add an entry to this table if the user creates a mail account in our server, but this is still not ideal. If the user add a mailbox in our server, and then changes to Google Apps, he would be required to delete the mail box in our server, or none of our other customers would be able to deliver mail to he, as he would still be in the virtual box table.
What can I do different here to not be required to create real users in our server for each hosted user, but still allowing our customers to use Google Apps?
Just to make it clear, what I want is:
- A totally functinonal SMTP, POP3 and IMAP server
- Users are required to authenticate themselves before sending mails, or before accessing their mailboxes (I am using dovecot to deal with the authentication:
password_query = SELECT email as user, password FROM EmailAccount WHERE email='%u'; this EmailAccount table is the same used for postfix to identify the virtual mailboxes) - Every e-mail sent using our mail server need to be delivered to the server configured in the MX record of the recipient domain. It doesn't matter if the domain of the recipient has any application hosted with us. E.g.: domain
example.commay be hosting an PHP application in our server, but it is using Google Appls to send/receive e-mails. Ee have an entry in the tableuserwith this domain, because one purchased a hosting service in our website. This table is the same used by postfix to identify virtual users. I want every customer from our company to be able to write to[email protected], and this e-mail must be delivered to Google because the MX record of example.com is pointing to Google Server. It should not be taken in account thatexample.comis a virtual mailbox; I want postfix to always fetch the MX record to find out the IP to deliver this message. - If later
example.comwants to host e-mails with us, I only want him to point his MX to our server and to create an email account in our server. So, we would insert a new record inEmailAcounttable with the password that he should use to fetch e-mails (using POP3/IMAP) and to end e-mails (using SMTP). - If later he decides again to switch to Google Apps, I want him to only change his MX record to Google webserver, and our instance of postfix will no longer try to deliver to any e-mail of
example.comdomain to our own server.