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:
postmaster@lorem.com userTwo
ipsum@lorem.com userTwo
postmaster@example.org userOne
steve@example.org userOne
postmaster@website.net userOne
steve@website.net userOne
mike@website.net userThree
mary@website.net userTwo
When sending mail from steve@example.org to mike@website.net:
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=<55C001A5.9020907@example.org>
Aug 3 20:04:55 example postfix/qmgr[25311]: 8D70441402: from=<steve@example.org>, 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=<55C001A5.9020907@example.org>
Aug 3 20:04:56 example postfix/qmgr[25311]: 72CE941403: from=<steve@example.org>, 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] <steve@example.org> -> <steve@example.org>, Queue-ID: 8D70441402, Message-ID: <55C001A5.9020907@example.org>, mail_id: QciSwqBl84A4, Hits: 1.439, size: 583, queued_as: 72CE941403, 838 ms
Aug 3 20:04:56 example postfix/smtp[25430]: 8D70441402: to=<steve@example.org>, orig_to=<mike@website.net>, 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=<55C001A5.9020907@example.org>: saved mail to INBOX
Aug 3 20:04:56 example postfix/local[25377]: 72CE941403: to=<steve@example.org>, 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 steve@example.org's SENT box. Which is strange, no? SMTP from mike@website.net to steve@example.org 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.