# [postfix] Mail transport unavailable after update

## boudewijn

hi there

I've got a mailsetup for about 2 years, which is running mysql+postfix on a gentoo system. Maildir is the mailbox format, and I've used this howto:

http://www.gentoo.org/doc/en/virt-mail-howto.xml

A few days ago, I've updated the box again and ran etc-update (without compromising any mail-related configs afaik), but messages kept hanging in the postfix queue:

```
1842D383A2    36982 Sat Sep 15 02:00:04  *address*@boudewijnector.nl

                                                  (mail transport unavailable)

                                         *address*@mail.boudewijnector.nl

```

I've been looking around, helped by one of the bounces (used another email acocunt on another box):

```
<*snap*@Boudewijnector.nl>: maildir delivery failed: create maildir file

    /home/boudewijn/.maildir/tmp/1189861849.P29840.dionysos.boudewijnector.nl:

    Permission denied

```

The box has always saved my email to /home/vmail/<domain>/<user> instead of someone's ~. This has also been specified in the mysql database (maildir field in user table)

Just checked my mysql-*.cf, all of these seem to be okay. The user specified in these files is able to access the mailsql db, which also seems to be correct:

```
|  3 | *snap*@boudewijnector.nl   | *SNAP* |           | Boudewijn              | 1003 | 1003 | /home/vmail  | /home/vmail/boudewijnector.nl/boudewijn/.maildir/ |       | y       |

```

Postfix still has MySQL support compiled in:

```
dionysos postfix # postconf -m

btree

cidr

environ

hash

ldap

mysql

pcre

proxy

regexp

static

unix

```

Syslog says:

```
Sep 15 15:54:02 dionysos postfix/postfix-script: stopping the Postfix mail system

Sep 15 15:54:02 dionysos postfix/master[6092]: terminating on signal 15

Sep 15 15:54:03 dionysos postfix/postfix-script: starting the Postfix mail system

Sep 15 15:54:03 dionysos postfix/master[7001]: daemon started -- version 2.3.6, configuration /etc/postfix

Sep 15 15:54:03 dionysos postfix/qmgr[7008]: B186238409: from=<root@boudewijnector.nl>, size=571, nrcpt=1 (queue active)

Sep 15 15:54:03 dionysos postfix/qmgr[7008]: warning: connect to transport smtp-amavis: Connection refused

```

I've never even used amavis or clam, so why is it trying to use these? (although I presume this is not the primary error, but something else).

master.cf:

```
smtp      inet  n       -       n       -       -       smtpd -v

pickup    fifo  n       -       n       60      1       pickup

cleanup   unix  n       -       n       -       0       cleanup

qmgr      fifo  n       -       n       300     1       qmgr

tlsmgr    unix  -       -       n       1000?   1       tlsmgr

rewrite   unix  -       -       n       -       -       trivial-rewrite

bounce    unix  -       -       n       -       0       bounce

defer     unix  -       -       n       -       0       bounce

trace     unix  -       -       n       -       0       bounce

verify    unix  -       -       n       -       1       verify

flush     unix  n       -       n       1000?   0       flush

proxymap  unix  -       -       n       -       -       proxymap

smtp      unix  -       -       n       -       -       smtp

relay     unix  -       -       n       -       -       smtp

        -o fallback_relay=

showq     unix  n       -       n       -       -       showq

error     unix  -       -       n       -       -       error

discard   unix  -       -       n       -       -       discard

local     unix  -       n       n       -       -       local

virtual   unix  -       n       n       -       -       virtual

lmtp      unix  -       -       n       -       -       lmtp

anvil     unix  -       -       n       -       1       anvil

scache    unix  -       -       n       -       1       scache

maildrop  unix  -       n       n       -       -       pipe

  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}

old-cyrus unix  -       n       n       -       -       pipe

  flags=R user=cyrus argv=/usr/lib/cyrus/deliver -e -m ${extension} ${user}

cyrus     unix  -       n       n       -       -       pipe

  flags=hu user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${extension} ${user}

virt-cyrus     unix  -       n       n       -       -       pipe

  flags=hu user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${recipient} ${user}

uucp      unix  -       n       n       -       -       pipe

  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)

ifmail    unix  -       n       n       -       -       pipe

  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)

bsmtp     unix  -       n       n       -       -       pipe

  flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient

```

postconf output : http://pastebin.ca/698544 (due to it being quite large, I haven't posted it here).

I presume postfix isn't using the mysql-backend correctly, because of it trying to deliver messages to local folders.

Anybody having a clue?

----------

## steveb

Why are people following this old How-To? Or why have people followed the How-To but not used the chance to learn something while following the How-To?

Anyway... remove:

```
virtual_alias_domains = $virtual_alias_maps

virtual_mailbox_domains = ector-vanleeuwen.nl
```

Create /etc/postfix/virtual_mailbox_domains.cf:

```
# /etc/postfix/virtual_mailbox_domains.cf

#

# virtual_mailbox_domains = mysql:/etc/postfix/virtual_mailbox_domains.cf

user     = mailsql

password = $password

dbname   = mailsql

#hosts   = localhost

hosts    = unix:/var/run/mysqld/mysqld.sock

query    = SELECT domain FROM transport WHERE domain='%s' AND destination='virtual:'
```

Add:

```
virtual_mailbox_domains = mysql:$config_directory/virtual_mailbox_domains.cf
```

Reload Postfix and then check if virtual delivery is working again.

For the error with smtp-amavs: Check your database if it contains a reference to smtp-amavis transport. If not, then post the full master.cf here in the forum.

// SteveB

----------

## boudewijn

well at first: it's on the official gentoo website. it's not being stated as being old  :Wink: 

changed the items you described, but it's still not working.

master.cf:

```
dionysos postfix # cat master.cf

#

# Postfix master process configuration file.  For details on the format

# of the file, see the master(5) manual page (command: "man 5 master").

#

# ==========================================================================

# service type  private unpriv  chroot  wakeup  maxproc command + args

#               (yes)   (yes)   (yes)   (never) (100)

# ==========================================================================

smtp      inet  n       -       n       -       -       smtpd -v

#submission inet n       -       n       -       -       smtpd

#  -o smtpd_enforce_tls=yes

#  -o smtpd_sasl_auth_enable=yes

#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

#smtps     inet  n       -       n       -       -       smtpd

#  -o smtpd_tls_wrappermode=yes

#  -o smtpd_sasl_auth_enable=yes

#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

#628      inet  n       -       n       -       -       qmqpd

pickup    fifo  n       -       n       60      1       pickup

cleanup   unix  n       -       n       -       0       cleanup

qmgr      fifo  n       -       n       300     1       qmgr

#qmgr     fifo  n       -       n       300     1       oqmgr

tlsmgr    unix  -       -       n       1000?   1       tlsmgr

rewrite   unix  -       -       n       -       -       trivial-rewrite

bounce    unix  -       -       n       -       0       bounce

defer     unix  -       -       n       -       0       bounce

trace     unix  -       -       n       -       0       bounce

verify    unix  -       -       n       -       1       verify

flush     unix  n       -       n       1000?   0       flush

proxymap  unix  -       -       n       -       -       proxymap

smtp      unix  -       -       n       -       -       smtp

# When relaying mail as backup MX, disable fallback_relay to avoid MX loops

relay     unix  -       -       n       -       -       smtp

        -o fallback_relay=

#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5

showq     unix  n       -       n       -       -       showq

error     unix  -       -       n       -       -       error

discard   unix  -       -       n       -       -       discard

local     unix  -       n       n       -       -       local

virtual   unix  -       n       n       -       -       virtual

lmtp      unix  -       -       n       -       -       lmtp

anvil     unix  -       -       n       -       1       anvil

scache    unix  -       -       n       -       1       scache

#

# ====================================================================

# Interfaces to non-Postfix software. Be sure to examine the manual

# pages of the non-Postfix software to find out what options it wants.

#

# Many of the following services use the Postfix pipe(8) delivery

# agent.  See the pipe(8) man page for information about ${recipient}

# and other message envelope options.

# ====================================================================

#

# maildrop. See the Postfix MAILDROP_README file for details.

# Also specify in main.cf: maildrop_destination_recipient_limit=1

#

maildrop  unix  -       n       n       -       -       pipe

  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}

#

# The Cyrus deliver program has changed incompatibly, multiple times.

#

old-cyrus unix  -       n       n       -       -       pipe

  flags=R user=cyrus argv=/usr/lib/cyrus/deliver -e -m ${extension} ${user}

# Cyrus 2.1.5 (Amos Gouaux)

# Also specify in main.cf: cyrus_destination_recipient_limit=1

cyrus     unix  -       n       n       -       -       pipe

  flags=hu user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${extension} ${user}

# Cyrus with "virtdomains: yes"

# Also specify in main.cf: virtual_transport = virt-cyrus

virt-cyrus     unix  -       n       n       -       -       pipe

  flags=hu user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${recipient} ${user}

#

# See the Postfix UUCP_README file for configuration details.

#

uucp      unix  -       n       n       -       -       pipe

  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)

#

# Other external delivery methods.

#

ifmail    unix  -       n       n       -       -       pipe

  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)

bsmtp     unix  -       n       n       -       -       pipe

  flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient

dionysos postfix #

```

main.cf:

```

dionysos postfix # cat main.cf

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

unknown_local_recipient_reject_code = 550

debug_peer_level = 2

debugger_command =

         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

         xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = postdrop

html_directory = /usr/share/doc/postfix-2.3.6/html

manpage_directory = /usr/share/man

sample_directory = /etc/postfix

readme_directory = /usr/share/doc/postfix-2.3.6/readme

home_mailbox = .maildir/

myhostname=mail.boudewijnector.nl

mydomain=boudewijnector.nl

inet_interfaces=all

mydestination=chouffe.boudewijnector.nl, dionysos.boudewijnector.nl, localhost.boudewijnector.nl, boudewijnector.nl

mynetworks=192.168.1.0/24, 127.0.0.0/8

local_destination_concurrency_limit = 2

default_destination_concurrency_limit = 10

smtpd_sasl_auth_enable = yes

smtpd_sasl2_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_sasl_local_domain =

smtpd_recipient_restrictions =

        permit_sasl_authenticated,

        permit_mynetworks,

        reject_unauth_destination

smtp_use_tls = yes

smtp_tls_note_starttls_offer = yes

smtpd_use_tls = yes

#smtpd_tls_auth_only = yes

smtpd_tls_key_file = /etc/postfix/newkey.pem

smtpd_tls_cert_file = /etc/postfix/newcert.pem

smtpd_tls_CAfile = /etc/postfix/cacert.pem

smtpd_tls_loglevel = 3

smtpd_tls_received_header = yes

smtpd_tls_session_cache_timeout = 3600s

tls_random_source = dev:/dev/urandom

alias_maps = mysql:/etc/postfix/mysql-aliases.cf

relocated_maps = mysql:/etc/postfix/mysql-relocated.cf

local_transport = local

local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname

virtual_transport = virtual

#virtual_mailbox_domains = ector-vanleeuwen.nl

virtual_minimum_uid = 1000

# (Substitute $vmail-gid with the GID of the vmail group)

 virtual_gid_maps = static:1003

virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf

virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf

virtual_uid_maps = static:1003

virtual_mailbox_base = /

 #virtual_mailbox_limit =

virtual_mailbox_domains = mysql:$config_directory/virtual_mailbox_domains.cf

```

----------

## steveb

Remove the space in front of "virtual_gid_maps". Then try again. If this does not work, then revert back to your old configuration and try again. Let me know if this works.

// SteveB

----------

## boudewijn

doesn't work.

this config is the new one after not being able to get the old one to work again.

can this be a revdep-rebuild related problem?

----------

## steveb

Wait a minute....

```
local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname
```

What does the $virtual_mailbox_maps search in the local recipient map?

// SteveB

----------

## boudewijn

changed it.

still not working   :Mad: 

also: why did it work before updating? (and is it NOT working after doing so)

----------

