Postfix/Dovecot - Multiple Domains and Multiple Linux Accounts
I believe I've solved this problem, and hoping that this will serve as help for others who encounter this issue. A little disappointed that there wasn't a lot of help here, but I guess the act of writing it out may have helped. Anyway:
In main.cf
, the myorigin
and mydestination
variables need to be set to localhost. So:
myorigin = localhost
mydestination = localhost
Instead of using mydestination to handle domain assignment, switching to virtual domain mapping allows virtual users to get the mail they need.
virtual_alias_domains = hash:/etc/postfix/domains
Which means we need to also properly format the /etc/postfix/domains
file:
example.org #
example.com #
The comments simply fulfill the hash format, nothing more. A postmap
will be necessary on this file as well:
postmap /etc/postfix/domains
That should be it. All of the individual accounts will route email to the proper unix addresses, after the lookup through virtual domains is done.
I still have no idea what "expanding" to a user is, or what was posted by the other individual who had trouble, but it seems irrelevant for this particular issue.
I hope this helps someone else like me.
EDIT: Also remove everything in /etc/aliases
.
Related videos on Youtube
Mookman288
Updated on September 18, 2022Comments
-
Mookman288 almost 2 years
I have been trying to setup a new mail server to migrate from my VPS, as my host has decided to close its doors. The old server was running Exim/Courier (nearly a decade old at this point,) and I'm under the impression that Postfix/Dovecot would be simpler to setup. I haven't had that much luck, though.
What I'm looking to setup:
- Postfix
- Dovecot
- Maildir format
- Multiple domains
- Multiple accounts
- ClamAV
- SpamAssassin
I've been using Amavis to tie ClamAV and SpamAssassin together.
postconf -n:
alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no config_directory = /etc/postfix content_filter = smtp-amavis:[127.0.0.1]:10024 home_mailbox = Maildir/ inet_interfaces = all mailbox_command = /usr/lib/dovecot/deliver mailbox_size_limit = 0 milter_default_action = accept mydestination = localhost, /etc/postfix/domains myhostname = example.org mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 myorigin = /etc/mailname readme_directory = no recipient_delimiter = + relayhost = smtp_tls_security_level = may smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) smtpd_client_restrictions = reject_unknown_client_hostname, permit_sasl_authenticated smtpd_data_restrictions = reject_unauth_pipelining smtpd_helo_required = yes smtpd_helo_restrictions = reject_invalid_helo_hostname, reject_non_fqdn_helo_hostname smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_sasl_authenticated, reject_unauth_destination smtpd_sasl_auth_enable = yes smtpd_sasl_path = private/auth smtpd_sasl_security_options = noanonymous smtpd_sasl_type = dovecot smtpd_sender_restrictions = reject_unknown_sender_domain smtpd_tls_auth_only = yes smtpd_tls_cert_file = /etc/postfix/.pem smtpd_tls_key_file = /etc/postfix/.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_use_tls = yes virtual_alias_maps = hash:/etc/postfix/virtual
/etc/postfix/domains:
lorem.com example.org website.net
/etc/postfix/virtual:
[email protected] userTwo [email protected] userTwo [email protected] userOne [email protected] userOne [email protected] userOne [email protected] userOne [email protected] userThree [email protected] userTwo
When sending mail from [email protected] to [email protected]:
mail.log, mail.err:
Aug 3 20:04:55 example postfix/submission/smtpd[25424]: connect from my-hostname[68.xxx.xxx.xxx] Aug 3 20:04:55 example postfix/submission/smtpd[25424]: 8D70441402: client=my-hostname[68.xxx.xxx.xxx], sasl_method=PLAIN, sasl_username=userOne Aug 3 20:04:55 example postfix/cleanup[25429]: 8D70441402: message-id=<[email protected]> Aug 3 20:04:55 example postfix/qmgr[25311]: 8D70441402: from=<[email protected]>, size=583, nrcpt=1 (queue active) Aug 3 20:04:55 example postfix/submission/smtpd[25424]: disconnect from my-hostname[68.xxx.xxx.xxx] Aug 3 20:04:56 example postfix/smtpd[25434]: connect from localhost[127.0.0.1] Aug 3 20:04:56 example postfix/smtpd[25434]: 72CE941403: client=localhost[127.0.0.1] Aug 3 20:04:56 example postfix/cleanup[25429]: 72CE941403: message-id=<[email protected]> Aug 3 20:04:56 example postfix/qmgr[25311]: 72CE941403: from=<[email protected]>, size=991, nrcpt=1 (queue active) Aug 3 20:04:56 example postfix/smtpd[25434]: disconnect from localhost[127.0.0.1] Aug 3 20:04:56 example amavis[5148]: (05148-07) Passed CLEAN {RelayedInbound}, [68.xxx.xxx.xxx]:52874 [68.xxx.xxx.xxx] <[email protected]> -> <[email protected]>, Queue-ID: 8D70441402, Message-ID: <[email protected]>, mail_id: QciSwqBl84A4, Hits: 1.439, size: 583, queued_as: 72CE941403, 838 ms Aug 3 20:04:56 example postfix/smtp[25430]: 8D70441402: to=<[email protected]>, orig_to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=1, delays=0.13/0.01/0.01/0.84, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 72CE941403) Aug 3 20:04:56 example postfix/qmgr[25311]: 8D70441402: removed Aug 3 20:04:56 example dovecot: lda(steve): msgid=<[email protected]>: saved mail to INBOX Aug 3 20:04:56 example postfix/local[25377]: 72CE941403: to=<[email protected]>, relay=local, delay=0.12, delays=0.01/0/0/0.1, dsn=2.0.0, status=sent (delivered to command: /usr/lib/dovecot/deliver) Aug 3 20:04:56 example postfix/qmgr[25311]: 72CE941403: removed
I censored my IP and hostname. Now, note that line in the middle, where it says orig_to. When I receive the email, it's in [email protected]'s SENT box. Which is strange, no? SMTP from [email protected] to [email protected] works fine.
I found one other question that matches this:
Postfix: virtual_alias_maps delivering everything to one user despite new domain
Unfortunately, I don't understand the answer, and I don't believe our setups are identical.
So I'm thinking it has to do with mydestination and and my use of virtual maps... but I'm not quite sure how I set my destination and virtual domains, if what I've done so far doesn't work.
I've been searching for an answer to this seemingly easy question for a very long time, and I'm running out of solutions to try. I don't want to have Google run my mail, and I'd really like to have it run on this VPS.
Any help would be greatly appreciated. Thank you.
-
clement almost 9 yearsI could see
postfix/local
delivering the mail. Please check/etc/aliases
file if there is a redirect to[email protected]
formike
or any.forward
file exist for usermike
-
clement almost 9 yearsAlso what is the content of
/etc/mailname
? -
Mookman288 almost 9 years@clement, there's mailer-daemon, nobody, hostmaster, usenet, news, www, ftp, abuse, noc, security, and clamav. There's no .forward file. /etc/mailname is example.org. It really looks like it's being routed back to [email protected], and being routed from steve's account, therefore ending up in the sent folder. Thank you for your help.
-
Mookman288 almost 9 yearsUpdate 08/05: I received an email today from some newsletter spam, and it went into [email protected]'s inbox, despite being intended for [email protected]; not in the sent folder.
-
clement almost 9 years
[email protected]
expands to[email protected]
. can you continue this expansion further and you should reach[email protected]
. currently i don't have enough data to prove it.
-
sebix almost 9 years
The comments simply fulfill the hash format
Comments are not needed in these files, they are optional. -
sebix almost 9 years
Also remove everything in /etc/aliases.
This file is used for delivery of local mails, e.g. if cron or other system services send mails to root. You can define an alias for root to another local account which mails you read. But don't remove it please. -
Mookman288 almost 9 yearsSebix, I get an error doing postmap when I remove the comments. They are not optional.
-
sebix almost 9 years
/etc/aliases
is the default value ofalias_database
. For the postmap: These are warnings, not errors. -
Mookman288 almost 9 yearsI'm not sure how your
/etc/aliases
comment applies to my statement, other than to declare something found in the default conf. In regards to postmap, I don't believe your initial comment has any place here. Whether something is properly formatted or not does not indicate whether it will return. It will cause warnings if it is improperly formatted. It will not cause warnings if it is properly formatted. My statement makes sense. It is strangely misleading that you would mention they're optional, without explaining that failing to properly format the file will result in a warning.