• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 594
  • Last Modified:

Postfix user with multiple domains

I have a client who has multiple domains but wants to run them as alias domains. I use Postfix as my incoming mx and direct mail into destination servers from there. I would like to use the virtual_alias_maps to redirect the incoming mail to the main domain regardless of the domain it was addressed to.
The thing I'm looking for is something that would say, "send {any user}@domain2.com to {same user}@domain1.com" so I don't have to put in an individual line for each user.
Is this even possible?
0
scarpenter104
Asked:
scarpenter104
  • 4
  • 3
1 Solution
 
farzanjCommented:
Yes, it is possible.

First find the name of the table in your postfix system.

grep virtual_alias_maps /etc/postfix/main.cf | cut -d: -f2

Make sure that virtual_alias_maps line is not commented.

If you don't have it, put something like
virtual_alias_maps = hash:/etc/postfix/virtual

Once you find out what the name of the file is, you should put the following entry:
@mydomain.com             %1@anotherdomain.com
0
 
scarpenter104Author Commented:
Using the suggested syntax, the server actually tries to deliver the mail to the literal:
%1@anotherdomain.com

I assume %1 is supposed to resolve but it does not.
0
 
farzanjCommented:
Ok, here is the problem.  It was Sendmail syntax and I thought it might be same.

Now you have to do this:
1.  Try removing %1 and see what happens.
2.  Whether it works or not try the second suggestion I have.


In your postfix config file, make sure the following map is enabled.
smtp_generic_maps = hash:/etc/postfix/generic

Now, insert this line (modify domain names) into /etc/postfix/generic
@dom1.com      @dom2.com


  Please let me know about both of these.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
scarpenter104Author Commented:
Both suggestions work perfectly.
The generic file (I assumed I also had to do a "postmap generic", which I did) gave a slight twist:

Since the first method works on the recieve side it showed up in the logs as delivered to (user@dom2.com (originally user@dom1.com). The second method operates on the delivery side so it simply showed user@dom1.com in the log but delivered the mail to user@dom2.com.

Additionally, in the mail client, the first method maintained the actual sending domain and showed it was sent to user@dom1.com, while the second showed that it was sent to user@dom2.com.

Two excellect solutions that each are perfect for certain situations.
Thanks for the solutions.
0
 
farzanjCommented:
I am so glad it worked.

Where did you do "postmap generic"?  Please clarify.  I normally use sendmail.
0
 
scarpenter104Author Commented:
generic is a text file and we specified a hash in the config:

smtp_generic_maps = hash:/etc/postfix/generic

So after creating the text file you use:

postmap generic

to create the generic.db that postfix looks for.
0
 
farzanjCommented:
Oh, ok.  Thanks for for your response.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now