0

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:

  1. A totally functinonal SMTP, POP3 and IMAP server
  2. 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)
  3. 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.com may 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 table user with 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 that example.com is a virtual mailbox; I want postfix to always fetch the MX record to find out the IP to deliver this message.
  4. If later example.com wants 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 in EmailAcount table with the password that he should use to fetch e-mails (using POP3/IMAP) and to end e-mails (using SMTP).
  5. 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.com domain to our own server.
3
  • So what do you want postfix to do? For the domains for which you don't have mailboxes forward that to another mailserver? Commented Dec 29, 2023 at 1:59
  • Hi, I have edited my question . What I want is that postfix alway fetch the MX record of the domain to fetch the IP address of the destination mailserver. Commented Dec 30, 2023 at 19:40
  • That is what postfix automatically does it's built into it, that's how an MTA works. Commented Dec 30, 2023 at 22:59

1 Answer 1

1

If you want Postfix to relay the mail to this domain on Google Apps, you should list it in relay_domains, instead.

If you have configured a domain for local delivery, Postfix will handle it as a local domain and won't care about the MX records. The only way is to remove the domain from any of the configurations that cause it to be serviced locally.

7
  • Thanks for your response. To achieve this, I would have let all of my customers if they want to use Google Apps or not; Isn't there any setting to tell postfix to always fetch the MX record of recepients? Commented Dec 28, 2023 at 10:01
  • That's what you already do with locally hosted domains, so it is probably how you would like to handle these, too. Otherwise, you would be allowing outbound mail to any domain. Commented Dec 28, 2023 at 12:36
  • I am just asking because I never saw this kind of option in any host that I worked with. I never had to explictly tell them that I would use Google Apps to host my e-mails, just had to set the MX entry. But, if there is no way to achieve this with postfix, maybe they are using other SMTP server.. just confirm this, please, and I will accept your answer if I do not get any other that fits better with what I want. Commented Dec 28, 2023 at 13:56
  • Almost anything is possible with Postfix, but based on this question it is hard to understand what you exactly want. And you could end up with an open relay if you don't know what you are doing. Commented Dec 28, 2023 at 16:22
  • Hi, I have edited my question . please let me know if it is not clear yet; sometimes it is hard to explain because I am not specialist in e-mail deliverability issues. Commented Dec 30, 2023 at 19:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.