Multiple domains for Postfix
Hi everyone,
Another question. Say I have x.domain.com and y.domain.com and want to setup postfix to accept and send mail for both those domains. Both domains have the same ip address by the way. Do I have to create a virtual domain? I currently have x.domain.com setup correctly and everything is working fine. Now I want to create a new user who has user@y.domain.com, is this possible? Are there any good tutorials on how to do this? Thanks, Steve |
normally you'd just use the virtual_alias_domains variable to the additional domains you want. that would then deliver bob@y.domain.com to the same destination as bob@x.domain.com. if you need to be more specific than that you'd be looking ath a virtual_alias_map file.
|
Virtual alias domains works OK if you want all your email going to local user mailboxes. That means user1@x.domain.com and user1@y.domain.com are each going to have different Linux user accounts since they both can't have user1. This can be confusing to users and is harder to manage.
If you want each user1@x.domain.com and user1@y.domain.com account to have it's own mailbox but not a Linux user account, you need virtual mailboxes. This is how I do it on my Ubuntu Postfix box at home. **Make sure to back up your config files before making any changes!** First make sure Postfix has the virtual module available to use. Look for the virtual line in /etc/postfix/master.cf. If it's there (which it should) continue. Create an account that will have access to the virtual mailboxes directory and one for each domain to write to them. Code:
useradd vuser -u 2000 (or any uid you want above 1000) Code:
mkdir /var/spool/virtual_mailboxes Code:
mkdir /var/spool/virtual_mailboxes/x.domain.com Code:
user1@x.domain.com x.domain.com/user1/ 2001 2001 Code:
# !/bin/bash Code:
chmod 755 /etc/postfix/build_virtual_maps.sh Code:
user1@x.domain.com user2@y.domain.com Code:
## Virtual Mailboxes Postfix will now start delivering all incoming mail to those virtual mailboxes. The next step would be to set up your POP3 or IMAP server to allow users to get those emails. I use dovecot-pop3 and dovecot-imap. /etc/dovecot/dovecot.conf Code:
base_dir = /var/run/dovecot/ Code:
user1@x.domain.com::2001:2001::/var/spool/virtual_mailboxes/x.domain.com/:/bin/false:: Code:
chmod 740 /etc/dovecot/users Code:
#!/bin/bash Code:
chmod 755 /usr/sbin/mkdovecotpasswd Code:
touch /etc/dovecot/passwd Code:
mkdovecotpasswd user1@x.domain.com password To add a new user, add them to the /etc/virtual_build_map_source file, run /etc/postfix/build_virtual_maps.sh, add them to /etc/dovecot/users, and run the mkdovecotpasswd command to assign them a password. All your users can now retrieve mail via POP3 and IMAP (assuming your box is set to accept ports 110, 143, and 25 and/or have them forwarded from your router to your server) and users will be using their full email address as their username. Restart Postfix and dovecot and you should be good. |
One small detail....
Thanks for the detailed reply. It was invaluable.
Just one little detail: I followed these steps to the letter and found that my postfix server was bouncing email to valid virtual user accounts. A bit of research determined that the problem was that I hadn't included the 'virtual_transport = virtual' parameter in /etc/postfix/main.cf. After adding that, everything worked fine. P.S. I was inspired by your script, and re-wrote the whole thing in perl and in a somewhat more comprehensive format. I'll post it here as soon as I have the pod documentation completed..... |
This one, if you are interested on trying, it uses MySQL in setting virtual domains/hosting. This is the tutorial I followed and my Slack-based postfix server based on.
http://www.postfixvirtual.net/postfixconf.html --------- GANI |
I'm glad I could help. I got most of my info from "The Book of Postfix" by Ralf Hildebrandt and Patrick Koetter. AWESOME BOOK!
My next task is to set up Postfix and LDAP. We have it running where I work but I'd like to try it on my own. |
All times are GMT -5. The time now is 02:36 AM. |