# postfix + dovecot Not reveiving Email [solved]

## jpnag

Hi,

I have decided to migrate from qmail+vpopmail+courier-authlib to postfix+dovecat but I'm having difficulties to set up postfix.

Apparently I have started the daemon however there is no process listening on port 25, and when I try to stop the daemon I get an error.

So I have two questions for anyone that may help, how can I debug my postfix configuration? I have tried 

```
postfix check
```

 but it returns nothing (I'm assuming that should be expected behaviour for a correct configuration), and second, and much more simple I assume, how do I tell the 

```
/etc/init.d/postfix
```

 script that postfix is actually not running without rebooting the machine?

If anyone can help that would be very helpful.

Thanks and regards!

----------

## notHerbert

 *jpnag wrote:*   

> how do I tell the 
> 
> ```
> /etc/init.d/postfix
> ```
> ...

 

```
/etc/init.d/postfix zap
```

Check the smtp and smtpd sections of your main.cf.   :Razz: 

----------

## overkll

Don't forget to check your log files.  Postfix may be misconfigured and refuse to start.  Postfix will/should log the error.

----------

## jpnag

Hi!

thanks a lot notHerbert, the zap worked! I'll note that down  :Wink: 

Although I do still have a problem since I cannot recieve or send email messages. After some investigation I found out this in my logs.

```

Nov 19 23:25:41 jpnag postfix/smtpd[7577]: fatal: unknown service: ]/tcp

Nov 19 23:25:42 jpnag postfix/master[6821]: warning: process /usr/lib/postfix/smtpd pid 7577 exit status 1

Nov 19 23:25:42 jpnag postfix/master[6821]: warning: /usr/lib/postfix/smtpd: bad command startup -- throttling

Nov 19 23:25:56 jpnag postfix/cleanup[7579]: fatal: unknown service: ]/tcp

Nov 19 23:25:57 jpnag postfix/master[6821]: warning: process /usr/lib/postfix/cleanup pid 7579 exit status 1

Nov 19 23:25:57 jpnag postfix/master[6821]: warning: /usr/lib/postfix/cleanup: bad command startup -- throttling

```

At first I thought the problem could only be in the master.cf file but I can't find any issue in there, weird that "]" in the error message... Any ideas? Anyone?

Thanks in advance!

----------

## notHerbert

Ok, post your uncommented master.cf

```
sed 's/#.*//;/^\s*$/d' /etc/postfix/master.cf
```

----------

## jpnag

Follows below.

```

smtp      inet  n       -       n       -       -       smtpd

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

proxywrite unix -       -       n       -       1       proxymap

smtp      unix  -       -       n       -       -       smtp

relay     unix  -       -       n       -       -       smtp

        -o smtp_fallback_relay=

showq     unix  n       -       n       -       -       showq

error     unix  -       -       n       -       -       error

retry     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

dovecot   unix  -       n       n       -       -       pipe

  flags=DRhu user=mail:mail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient} -v-v

```

----------

## overkll

Unknown service....

What's the output of

```
grep "]" /etc/services
```

?

----------

## timeBandit

Moved from Portage & Programming to Networking & Security.

----------

## jpnag

Hi,

thanks for all your help.

I have managed to found the root of the problem after increasing the logs verbosity

```

Nov 20 08:27:16 jpnag postfix/smtpd[10273]: fatal: bad net/mask pattern: "192.0.0.0/255"

```

this is related with a configuration in my main.cf file

```

mynetworks = 192.0.0.0/255, 127.0.0.0/8

```

I just have to dig in the postfix documentation to find out how can I add all 192.xxx.xxx.xxx IPs to my allowed IP, but if you know that please fell free to share.

Thanks!

----------

## meal

you've got bad class given, should be 192.168.0.0 instead of 192.0.0.0 and there is no such mask as /255, it should be /255.255.255.0 or /24

----------

## elgato319

```
192.0.0.0/8 - Class A Network

192.x.0.0/16 - Class B Network

192.x.y.0/24 - Class C Network
```

of course you could be on a subnetted network. depends on your lan config.

----------

## overkll

IIRC, you don't even need to set the "mynetworks" parameter in postfix.  It will determine "mynetworks" from the system settings.  The only time you need to set "mynetworks" is if you need to use additional and/or different settings than your machine already uses.  For example, if you have a dual homed machine (2 nics) and you don't want the external nic to be a trusted network, then you would define mynetworks, otherwise postfix would automatically trust the external nic as well by default.

Dual homed machine - Postfix autodetect

```
# postconf mynetworks

mynetworks = 127.0.0.0/8 10.0.0.0/24 70.124.48.0/20
```

Manually set to trust just the inside nic

```
# postconf mynetworks

mynetworks = 127.0.0.0/8 10.0.0.0/24
```

If you really wanted to, you could also set "mynetworks = 127.0.0.1/8 192.0.0.0/8", but I don't think you own all those IPs in the 192.x.x.x range, do you?  If you want to trust them, that's your decision.

----------

## jpnag

Actually those IPs (192.168.0.xxx) are inside a private network, but I'll have a deeper look at that as soon as I have this running. At the moment I still have one error in my logs and I cannot receive email messages. I'm not sure if I can send but I believe I can based on this:

```

Nov 21 09:35:04 jpnag postfix/smtp[12671]: B1A32F5641: to=<xxxxx@xxxxxx>, relay=relay.xxxxxxx.xx[xxx.xxx.xxx.xxxx]:25, delay=1.1, delays=0.09/0.04/0.77/0.15, dsn=4.0.0, status

=deferred (host relay.xxxxxxx.xxx[xxx.xxx.xxx.xxx] said: 451 http://www.spamhaus.org/query/bl?ip=xxx.xxx.xxx.xxx(in reply to RCPT TO command))

```

The error I'm getting is:

```

postfix/smtpd[12930]: dict_eval: const  error

```

Honestly I dind't had the time to carefully search this but if you have a lead for me to follow that would be nice.

Thanks and regards!

----------

## jpnag

This would probaly deserve a fresh post since my initial problems are gone...but new ones arrised!

I'm now able to send emails but I still not managed to receive and I have no idea why.

Any ideas on how I should debug the problem?

Thanks!

----------

## meal

Send e-mail to this host and run 

```
tail -f /var/log/mail.log
```

 or whatever where you keep your mail logs. You should see an notice about what's doing.

----------

## jpnag

Hi,

after some debug I found out that the problem might not be in postfix but in dovecot, at least that's my convinction based on this line in dovecot logs:

```

dovecot: Nov 23 15:32:22 Info: auth(default): new auth connection: pid=28835

dovecot: Nov 23 15:32:25 Info: auth(default): master in: USER   1       xxxx@xxxx.xxxxxxxx.xxx service=deliver

dovecot: Nov 23 15:32:25 Error: auth(default): prefetch(xxxx@xxxx.xxxxx.xxx): passdb didn't return userdb entries

dovecot: Nov 23 15:32:25 Info: auth(default): master out: NOTFOUND      1

```

Following this lead now. As previously any help is welcome  :Smile: 

Thanks!

----------

## jpnag

GOT IT!

Took me while to figure this one out!

my dovecot-sql.conf was using the following to db query:

```

password_query = SELECT CONCAT('/var/mail/', maildir) AS userdb_home, username as user, password, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active = 1

```

And I had to change it to

```

password_query = SELECT username as user, password FROM mailbox WHERE username = '%u' AND active = 1

user_query = SELECT CONCAT('/var/mail/', maildir) AS home, CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active = 1

```

These should be equivalent....but it seems they are not!

Thanks for all the help guys!

PS - In case this can be useful to anyone else having the same problem don't forget to also change your dovecot.conf from:

```

auth default {      

  mechanisms = plain login

  passdb sql {

    args = /etc/dovecot/dovecot-sql.conf

  }

  userdb prefetch {         

  }

....

```

to: 

```

auth default {      

  mechanisms = plain login

  passdb sql {

    args = /etc/dovecot/dovecot-sql.conf

  }

  userdb sql {

    args = /etc/dovecot/dovecot-sql.conf

  }

  userdb prefetch {         

  }

...

```

----------

