[toc]
How do I set up a catch-all email address to receive or bounce invalid inbound emails?
Note that this is not recommended. It breaks the ability of the mail server to reject mail early in the delivery process, which means your system will work dramatically harder because full spam messages and viruses will have to go through the full processing chain. It is far better to create every alias you need, as you need them.
- Virtualmin
- Choose the domain name of your server from the pull-down menu
- Click "Edit Mail Aliases"
- Click "Add an alias to this domain"
- Set "Name" to "All mailboxes"
- Fill in the delivery settings as usual (a local mailbox, usually).
- Click "Bounce mail?" if you want to use this catch-all email account to bounce inbound emails with invalid email addresses.
To "turn off" the automatic email bouncing, simply delete this catch-all email alias.
Why is All Incoming Email Bouncing?
That can occur if your hostname gets out of sync with what's setup in your server's config files.
To check for this problem, log into your server as root over SSH, and run the command "hostname". Then, verify that the resulting hostname exists next to your external facing IP address in /etc/hosts, as well as on the "mydestination" line of /etc/postfix/main.cf. After making those changes, restart Postfix.
What's the deal with @ in mailbox usernames?
It's a bad idea, according to Wietse Venema in this post on the Postfix mailing list: http://archives.neohapsis.com/archives/postfix/2000-02/0892.html
Virtualmin has several clever hacks to workaround this particular feature of Postfix, revolving around the creation of a second user with the same UID and paths, which Postfix can deliver to. This has many potential problems and might confuse other software that isn't smart enough to deal with multiple usernames with the same UID (this is perfectly legitimate, and ought to work, but it is a common failing and even some of our stuff has had some bugs uncovered, but now fixed, by this hack).
On many current distributions, the Cyrus saslauthd version defaults to dropping the "@domain.tld" portion of the username before attempting authentication. This, obviously, won't work. The solution is to add the "-r" flag to the saslauthd command. On Red Hat based systems, additional flags can be added in the "FLAGS=" section of the file /etc/sysconfig/saslauthd. On Debian-based systems, the file to edit is /etc/default/saslauthd and the directive to modify is "PARAMS=". This is an orthogonal issue to the Postfix issues, and will occur whether you use Sendmail or Postfix as your mail server.
We don't recommend using @ in the username for mailbox users (for the same reasons that Wietse removed support for them in Postfix), but if you must it can be done. Any problems you run into should be brought up in the Bug Tracker, so we can get them resolved. Just because it's a hack doesn't mean we won't make it work as well as any othe naming convention.
Also note that this trick is incompatible with mbox style mail spools (because mail will be delivered to the "wrong" mailbox: user-domain.tld, instead of user@domain.tld). Maildir format mail spools are not subject to this problem, and are the default in Virtualmin if you have used our automated installation script.
If you really do want to use this type of username, edit the Server Template(s) for which you'd like this type of username. Browse to the "Mail for domain" section (select it in the dropdown, if using the Virtualmin theme, or scroll to this section if using any non-menu-ized theme). Find the option labeled "Format for usernames that include domain", and select "user@domain", and save your changes.