# Postfix & virtual mail issue



## Leander (Feb 2, 2015)

Hi
Somehow I have a missunderstanding in my Postfix configuration - but I can't figure out where I went wrong. Postfix keeps on complaining, that it doesn't have a valid transport. Debugging the problem resulted in following logs:

```
postfix/qmgr[68535]: resolve_clnt: `test@MyDomain.Local' -> `test@MyDomain.Local' -> transp=`ldap' host=`/usr/local/etc/postfix/ldap/virtual_transport.cf' rcpt=`test@MyDomain.Local' flags= class=virtual
postfix/qmgr[68535]: connect to subsystem private/ldap: No such file or directory
postfix/qmgr[68535]: warning: connect to transport private/ldap: No such file or directory
postfix/qmgr[68535]: scan_dir_pop: close incoming
postfix/qmgr[68535]: done incoming queue scan
postfix/qmgr[68535]: transport_event: ldap
postfix/qmgr[68535]: qmgr_transport_throttle: transport ldap: status: 4.3.0 reason: mail transport unavailable
postfix/qmgr[68535]: defer transport ldap: 4.3.0 mail transport unavailable
```
According to my understanding virtual_transport.cf should deliver this information - but somehow Postfix does not accept it?! Yet a manual `postmap -q test@MyDomain.Local ldap:/usr/local/etc/postfix/ldap/virtual_transport.cf` delivers expected result `dovecot`. What could be wrong here?
This is the relevant part of my main.cf

```
virtual_alias_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_aliases.cf
virtual_mailbox_domains = ldap:/usr/local/etc/postfix/ldap/virtual_domains.cf
#virtual_alias_domains  = ldap:/usr/local/etc/postfix/ldap/virtual_alias_domains.cf
virtual_mailbox_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_mailboxes.cf
virtual_uid_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_uid.cf
virtual_gid_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_gid.cf
virtual_transport  = ldap:/usr/local/etc/postfix/ldap/virtual_transport.cf
transport_maps = ldap:/usr/local/etc/postfix/ldap/transport_maps.cf
relay_domains  = ldap:/usr/local/etc/postfix/ldap/virtual_relay.cf
```
Here is a graph of my the LDAP structure behind it:




/usr/local/etc/postfix/ldap/virtual_aliases.cf

```
search_base = ou=accounts,ou=mail,dc=mydomain,dc=local
query_filter = ( mailAddress=%s )
result_attribute = mailAlias
```
/usr/local/etc/postfix/ldap/virtual_domains.cf

```
search_base = ou=domains,ou=mail,dc=mydomain,dc=local
query_filter = ( dc=%s )
result_attribute = dc
```
/usr/local/etc/postfix/ldap/virtual_mailboxes.cf

```
search_base = ou=accounts,ou=mail,dc=mydomain,dc=local
query_filter = ( mailAddress=%s )
result_attribute = mailStorageDirectory
```
/usr/local/etc/postfix/ldap/virtual_uid.cf

```
search_base = ou=accounts,ou=mail,dc=mydomain,dc=local
query_filter = ( mailAddress=%s )
result_attribute = mailUidNumber
```
/usr/local/etc/postfix/ldap/virtual_gid.cf

```
search_base = ou=accounts,ou=mail,dc=mydomain,dc=local
query_filter = ( mailAddress=%s )
result_attribute = mailGidNumber
```
/usr/local/etc/postfix/ldap/virtual_transport.cf

```
search_base = ou=accounts,ou=mail,dc=mydomain,dc=local
query_filter = ( mailAddress=%s )
result_attribute = mailDelivery
```
/usr/local/etc/postfix/ldap/transport_maps.cf

```
search_base = ou=forward_domains,ou=mail,dc=mydomain,dc=local
query_filter = ( dc=%s )
result_attribute = dc
```
/usr/local/etc/postfix/ldap/virtual_relay.cf

```
search_base = ou=forward_domains,ou=mail,dc=mydomain,dc=local
query_filter = (associatedDomain=%s)
result_attribute = associatedDomain
```


----------



## igorino (Feb 5, 2015)

Just guessing:
Do you have set up _relay_transport_ parameter in your main.cf?
Other than running postmap manually, he can read those files, he is aware of the necessary environment variables?


----------



## Leander (Feb 5, 2015)

Meanwhile I figured it out. Here is my solution if you plan on having

a mail server with virtual user/mail accounts
as well as a mail server which is capeable of forwarding entire domains (postfix relay)


```
### Virtual Accounts
#

# Validate recipient address
virtual_mailbox_domains = ldap:/usr/local/etc/postfix/ldap/virtual_mailbox_domains.cf

virtual_uid_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_uid_maps.cf
virtual_gid_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_gid_maps.cf

# Optional lookup tables that alias specific mail addresses or domains to other local or remote address
#virtual_alias_domains  = ldap:/usr/local/etc/postfix/ldap/virtual_alias_domains.cf
virtual_alias_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_alias_maps.cf

# Get individual Mail Storage Location
virtual_mailbox_maps  = ldap:/usr/local/etc/postfix/ldap/virtual_mailbox_maps.cf

# Virtual default next hop after content filtering (defined in master.cf)
virtual_transport  = dovecot

# Don't parse multiple recipients at once for dovecot-lda(1) / deliver(1)
dovecot_destination_recipient_limit = 1


### Relay Transport
#

# What destination domains (and subdomains thereof) this system will relay mail to. %s is the domain
relay_domains  = ldap:/usr/local/etc/postfix/ldap/relay_domains.cf

# The default mail delivery transport and next-hop destination for remote delivery to domains listed with $relay_domains.
relay_transport = ldap:/usr/local/etc/postfix/ldap/relay_transport.cf

# This overrides the default of virtual_transport. It may be required for individual forwards based on individual addresses - eg. for mailman.
transport_maps  = ldap:/usr/local/etc/postfix/ldap/transport_maps.cf
```


----------

