7

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.

6
  • 1
    I could see postfix/local delivering the mail. Please check /etc/aliases file if there is a redirect to [email protected] for mike or any .forward file exist for user mike
    – clement
    Aug 4, 2015 at 4:37
  • 1
    Also what is the content of /etc/mailname?
    – clement
    Aug 4, 2015 at 4:44
  • @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
    Aug 4, 2015 at 6:25
  • Update 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.
    – Mookman288
    Aug 5, 2015 at 16:27
  • [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.
    – clement
    Aug 6, 2015 at 5:08

1 Answer 1

8

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.

6
  • The comments simply fulfill the hash format Comments are not needed in these files, they are optional.
    – sebix
    Aug 16, 2015 at 19:10
  • 2
    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.
    – sebix
    Aug 16, 2015 at 19:11
  • 1
    Sebix, I get an error doing postmap when I remove the comments. They are not optional.
    – Mookman288
    Aug 16, 2015 at 19:28
  • In regard to /etc/aliases, while this file is used for delivery of local mails in a traditional setup, in my situation it had no value and was a detriment to important system service notification. In an environment where no myorigin or mydestination is set, or set to localhost. I found that when this file was enabled, it would override the destination even if virtual aliases were set. If it cannot be removed, then I effectively lose important system service emails. I see no other solution.
    – Mookman288
    Aug 16, 2015 at 19:33
  • /etc/aliases is the default value of alias_database. For the postmap: These are warnings, not errors.
    – sebix
    Aug 16, 2015 at 19:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .