Postfix delivering to /var/mail instead of /var/vmail

Dear users,

I'm a newcomer to FreeBSD and enjoying the experience.

Today I'm stuck with this problem: Postfix delivers my email to /var/mail instead of /var/vmail! I'm using it with dovecot.

Below is a dump of my configuration files. Help will be very appreciated!

Thank you for your time.

The content of /var/log/maillog:
Code:
ep 14 13:11:13 MAILSERVER postfix/cleanup[37520]: EE90A82AC4: message-id=<20130914131113.EE90A82AC4@example.com>
Sep 14 13:11:13 MAILSERVER opendkim[38824]: EE90A82AC4: localhost [127.0.0.1] not internal
Sep 14 13:11:13 MAILSERVER opendkim[38824]: EE90A82AC4: not authenticated
Sep 14 13:11:13 MAILSERVER opendkim[38824]: EE90A82AC4: external host localhost attempted to send as example.com
Sep 14 13:11:13 MAILSERVER postfix/qmgr[37463]: EE90A82AC4: from=<root@example.com>, size=361, nrcpt=1 (queue active)
Sep 14 13:11:13 MAILSERVER postfix/local[37522]: EE90A82AC4: to=<a@example.com>, relay=local, delay=0.02, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Sep 14 13:11:13 MAILSERVER postfix/qmgr[37463]: EE90A82AC4: removed

Code:
postconf -n
command_directory = /usr/local/sbin
config_directory = /usr/local/etc/postfix
daemon_directory = /usr/local/libexec/postfix
data_directory = /var/db/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
dovecot_destination_recipient_limit = 1
html_directory = /usr/local/share/doc/postfix
inet_protocols = ipv4
mail_owner = postfix
mailq_path = /usr/local/bin/mailq
manpage_directory = /usr/local/man
milter_default_action = accept
mydomain = example.com
myhostname = example.com
mynetworks_style = host
newaliases_path = /usr/local/bin/newaliases
non_smtpd_milters = $smtpd_milters
queue_directory = /var/spool/postfix
readme_directory = /usr/local/share/doc/postfix
sample_directory = /usr/local/etc/postfix
sendmail_path = /usr/local/sbin/sendmail
setgid_group = maildrop
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtpd_banner = example.com SMTP Server
smtpd_milters = inet:127.0.0.1:8891
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_pipelining,
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = example.com
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_sender_domain, reject_unauth_pipelining,
smtpd_tls_CAfile = /usr/local/etc/postfix/ssl/smtpd.pem
smtpd_tls_cert_file = /usr/local/etc/postfix/ssl/smtpd.pem
smtpd_tls_key_file = /usr/local/etc/postfix/ssl/smtpd.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
spf-policy_time_limit = 3600s
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_gid_maps = static:1002
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps = hash:/usr/local/etc/postfix/virtual/mailbox
virtual_maps = hash:/usr/local/etc/postfix/virtual/addresses
virtual_minimum_uid = 100
virtual_transport = dovecot
virtual_uid_maps = static:1002

Code:
dovecot -n
# 2.2.5: /usr/local/etc/dovecot/dovecot.conf
# OS: FreeBSD 9.1-RELEASE-p7 amd64  zfs
auth_debug = yes
auth_debug_passwords = yes
auth_mechanisms = plain login cram-md5 digest-md5
auth_verbose = yes
disable_plaintext_auth = no
info_log_path = /var/log/dovecot.log
listen = *
log_path = /var/log/dovecot.log
login_greeting = Mail Server
mail_gid = vmail
mail_location = maildir:/var/vmail/%n/Maildir
mail_privileged_group = vmail
mail_uid = vmail
passdb {
args = /usr/local/etc/dovecot/passwords
driver = passwd-file
}
protocols = imap
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
}
service imap-login {
chroot = login
client_limit = 256
executable = /usr/local/libexec/dovecot/imap-login
inet_listener imap {
address = *
port = 143
}
inet_listener imaps {
address = *
port = 993
}
process_limit = 128
process_min_avail = 2
service_count = 1
}
service imap {
executable = /usr/local/libexec/dovecot/imap
}
ssl = no

Code:
tail master.cf
#  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store
#  ${nexthop} ${user} ${extension}
#
#mailman   unix  -       n       n       -       -       pipe
#  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
#  ${nexthop} ${user}
spf-policy   unix  -       n       n       -       0       spawn
  user=nobody argv=/usr/local/sbin/postfix-policyd-spf-perl
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/local/libexec/dovecot/dovecot-lda -f ${sender} -d ${recipient}
 
tw9JRlkTEjXpoUlo09jc said:
Code:
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps = hash:/usr/local/etc/postfix/virtual/mailbox
virtual_maps = hash:/usr/local/etc/postfix/virtual/addresses
virtual_minimum_uid = 100
virtual_transport = dovecot
When in doubt always check the manual ;)

Although you set virtual_mailbox_base there is one small caveat to keep in mind; it will only be honoured if you're using Postfix' own virtual transport agent. From the postconf(5) manual page:

Code:
virtual_mailbox_base (default: empty)

   A prefix that the virtual(8) delivery agent prepends to all pathname results from
   $virtual_mailbox_maps table lookups. This is a safety measure to ensure that an out
   of control map doesn't litter the file system with mailboxes. While virtual_mailbox_base
   could be set to "/", this setting isn't recommended.

   This parameter is specific to the virtual(8) delivery agent. It does not apply when
   mail is delivered with a different mail delivery program.
And as can be seen above you're using dovecot as the mail delivery program (actually you're probably using deliver which is the Dovecot delivery agent). This is why your e-mail ends up in /var/mail since that is the normal (default) location for it. If you need to change this then you should configure virtual which is normally done by changing the definition in master.cf.

This maybe a good read for all this.

But I can't help wonder why don't you turn things around? Instead of trying to alter Postfix simply tell Dovecot to look into /var/mail instead.

There are several ways to do so, the most obvious one would be to change the mail_location in dovecot.conf.

Hope this can help.
 
You made me think and I changed my setup. I now deliver the mails in the user directory and without the virtual setup.

main.cf has now:
Code:
home_mailbox = Maildir/
mailbox_transport = lmtp:unix:private/dovecot-lmtp

dovecot.conf defines:

Code:
service lmtp {
 unix_listener /var/spool/postfix/private/dovecot-lmtp {
   group = postfix
   mode = 0600
   user = postfix
  }
}

However I get the following error:
Code:
Sep 14 22:54:05 MAILSERVER postfix/lmtp[49442]: C6EEA8261A: to=<john@example.com>, orig_to=<john>, relay=example.com[private/dovecot-lmtp], delay=0.03, delays=0.01/0.01/0.01/0, dsn=4.4.2, status=deferred (lost connection with example.com[private/dovecot-lmtp] while sending MAIL FROM)
 
Personally I'd skip the Dovecot delivery agent and instead either use the default for Postfix or rely on something like Procmail. The advantage of using a separate delivery agent is that you can get more control over the way your message is being delivered (for example by applying specific spam or virus filters).
 
I want to deliver with Dovecot to later use the sieve plugin. I was able to solve the problem. The local agent of Postfix was used to deliver instead of the Dovecot one.

Setting
Code:
local_transport = dovecot
in main.cf solved the problem.
 
Back
Top