# Postfix installation problem



## studyete (Jun 28, 2013)

Hi, I have started using FreeBSD recently. I am trying to configure _the_ Postfix mail server using Purplehat's tutorial. I have Googled below issue but I'm not getting any good solution yet. I have tried below link but apparently the issue is not related with mine. Any help would _be_ highly appreciated.  

http://forums.freebsd.org/showthread.php?t=6711

_The_ error I am facing_:_


```
postfix: warning: valid_hostname: empty hostname
postfix: fatal: unable to use my own hostname
*** [do-install] Error code 1

Stop in /usr/ports/mail/postfix.
*** [/usr/ports/mail/postfix/work/.install_done.postfix._usr_local] Error code 1

Stop in /usr/ports/mail/postfix.
*** [run-depends] Error code 1

Stop in /usr/ports/security/maia.
```


----------



## SirDice (Jun 28, 2013)

Did you set a proper hostname in /etc/rc.conf?


----------



## studyete (Jun 28, 2013)

No, I did not, I have given the hostname just now and th_e_n again run `make all install clean`. It's now counting. I'll get back if I face the same error again.


----------



## studyete (Jun 29, 2013)

_The p_revious issue has resolved. Thanks for noticing it. But now I'm facing another problem and I don't know from where to start. At _P_ostfix admin setup, when I tried to start _P_ostfix by _the_ following command, I got _an_ error. I do not want to open another thread, therefore, I am placing the issue here.

```
#/usr/local/etc/rc.d/postfix start
/usr/local/etc/rc.d/postfix: Command not found.
```


----------



## studyete (Jun 29, 2013)

*T*here is no file or anything named postfix at /usr/local/etc/rc.d/postfix though.


----------



## studyete (Jun 29, 2013)

Just providing the error I got when tried to `make install clean` from _the_ port of _P_ostfix.

```
postfix: fatal: /usr/local/etc/postfix/main.cf, line 28: missing '=' after attribute name: "permit_mynetworks"
*** [do-install] Error code 1

Stop in /usr/ports/mail/postfix.
*** [/usr/ports/mail/postfix/work/.install_done.postfix._usr_local] Error code 1

Stop in /usr/ports/mail/postfix.
```

I have used @pupalhat's tutorial _on_ installing _P_ostfix.


----------



## studyete (Jun 29, 2013)

I apologizes for posting again and again with _a_ lot of silly matter which I am solving just after posting a few minute_s ago_. But I am unable to resolve below problem for almost _two_ hour_s_. I think *I* need _a_ member's help regarding it. I am trying to connect by `telnet localhost 110`. I got the following error. I don't know what to do. Please forget above issues and kindly help regarding this.

```
[CMD=root@mail:/root #]telnet localhost 110[/CMD]
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK AON Mail Server Ready.
[CMD]user example@example.info[/CMD]
+OK
[CMD]pass tah321#[/CMD]
-ERR [IN-USE] Temporary authentication failure.
Connection closed by foreign host.
```

My dovecot.log _is_ showing _the_ following. 

```
Jun 29 16:46:01 auth-worker(default): Error: mysql: Connect failed to localhost (postfix): Access denied for user 'postfix'@'localhost' (using password: YES) - waiting for 1 seconds before retry
Jun 29 16:55:20 auth-worker(default): Error: mysql: Connect failed to localhost (postfix): Access denied for user 'postfix'@'localhost' (using password: YES) - waiting for 5 seconds before retry
Jun 29 16:55:20 auth-worker(default): Error: sql(example@example.info,127.0.0.1): Password query failed: Not connected to database
```

My mail log _is_ showing _the_ following:

```
Jun 29 16:32:55 mail dovecot: pop3-login: Aborted login (auth failed, 1 attempts): user=<example@example.info>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
```


----------



## gkontos (Jun 29, 2013)

Your database is not accepting the _P_ostifx login credentials. Most likely you just copied and paste the configuration.

Don't do that on a mail server. Learn the basic principles first!


----------



## ShelLuser (Jun 29, 2013)

I think everyone has experienced the moment when you write something up to ask a question and either during the time of writing or, as you just mentioned, just after it do you suddenly find the solution. We've all been there.

However, it would be appreciated if you could share your solution on the thread too, that might help other future readers as well.

But for your last problem though I do suggest starting a new thread. Because now you're entering a subject which no longer has much to do with Postfix. Postfix is merely an SMTP server, the moment you need POP3 or IMAP functionality you'll have to resort to something else. And as I can see you picked up Dovecot, which is a good choice in combination with Postfix in my opinion, but it's still a completely different program.

People who know their way around Postfix don't necessarily have to know about Dovecot and vice versa.

My advice would be to start over and don't use a SQL backend and such, but stick to plain text authentication and the passwd database file. That will determine where the problem resides, if that works you can take the next step: activating the SQL backend and try again.

Also; why does Dovecot use the Postfix user account? That's also not a default setting, and one which you really don't need. Just making the two processes share the mail group should be enough.


----------



## gkontos (Jun 29, 2013)

ShelLuser said:
			
		

> Also; why does Dovecot use the Postfix user account? That's also not a default setting, and one which you really don't need. Just making the two processes share the mail group should be enough.



It is the default setting in the guide that he tries to follow. It also makes sense if you understand how mail/postfixadmin works.


----------



## studyete (Jun 29, 2013)

Thanks all for your kind participation. I have started the thread with *the* title "Postfix installation problem" and thought I'll put all my hardships during this configuration in single thread. But now I'm feeling it would not be a good *i*dea. So I'll share the solutions of the problem *I* have faced in this thread and will open another thread as @ShelLuser advised.   

My first problem when I tried to start *P*ostfix with `/usr/local/etc/rc.d/postfix` I found *P*ostfix is not there. So I have run *the P*ostfix configuration again from /usr/ports/mail/postfix and end up with following error:

[quote]*[code]*

```
postfix: warning: valid_hostname: empty hostname
postfix: fatal: unable to use my own hostname
*** [do-install] Error code 1
```
[/QUOTE]*[/code]*

I have just edited *the* /etc/rc.conf file, put the host name *in* and rebooted the server. The issue resolved. The*n* again during *P*ostfix installation, I have faced *the* following error*:*

[quote]*[code]*

```
postfix: fatal: /usr/local/etc/postfix/main.cf, line 28: missing '=' after attribute name: "permit_mynetworks"
*** [do-install] Error code 1
```
[/QUOTE]*[/code]*

So I reopen *the* /usr/local/etc/postfix/main.cf file and found there is whitespace af*t*er = on that line. I guessed that whitespace occur*s* due to purplehate's format*t*ing at the web page. So *I* removed _all_ whitespace, br*ou*g*ht it* all on the same line or just removed the whitespace and then the issue resolved. I made the correction *the*following way.

[quote]*[code]*

```
smtpd_recipient_restrictions =
  permit_mynetworks,
  permit_sasl_authenticated,
  reject_non_fqdn_hostname,
```
[/QUOTE]*[/code]*

Instead *o*f that, *I* modified the file *the* following way:

```
smtpd_recipient_restrictions =  permit_mynetworks,  permit_sasl_authenticated,  reject_non_fqdn_hostname,
```
[/quote][/quote][/quote]*[/CODE]* 


Then after *P*ostfix *was* done, I was able to run *P*ostfix and fall with the last problem which is still not resolved. I have taken @ShelLuser's advi*c*e and reinstalled *the* OS again!


----------



## studyete (Jun 29, 2013)

@gkontos , I tried to follow the tutorial as it is as much as possible, though I have changed where it required. I found I can log on to database with following command

```
mysql -h localhost -u postfix -p postfix
```

With _the_ _P_ostfix password, I was able to connect to _the_ database, I have used _the_ same _P_ostfix password at /usr/local/etc/dovecot-sql.conf and dovecot-dict-sql.conf. If you think it would be good to share dovecot conf_iguration_ files here, I'll do it. 

I am just a beginner at unix system_s_ and trying to learn by using it. Whenever I face any issue I _G_oogle or turn to the community. Would you be kind to explain more on the issue _D_ovecot failing to connect database please? Is there other way around of authenticating?

@Sheluser, your comment is very hard to me, Could you explain it treating my level as beginner? 



> My advice would be to start over and don't use a SQL backend and such, but stick to plain text authentication and the passwd database file. That will determine where the problem resides, if that works you can take the next step: activating the SQL backend and try again.


----------



## ShelLuser (Jun 30, 2013)

studyete said:
			
		

> I am just a beginner at unix system and trying to learn by using it. Whenever I face any issue I google or turn to the community. Would you be kind to explain more on the issue dovecot failing to connect database please? Is there other way around of authenticating?
> 
> @Sheluser, your comment is very hard to me, Could you explain it treating my level as beginner?


Well, to start I didn't really hint at reinstalling the whole OS but merely Postfix and Dovecot. In general; if you ever make a complete mess of your system where several ports start to misbehave and there seems to be no other option but to start completely over then you'd only need to reinstall the ports.

Keep in mind that FreeBSD basically consists of 2 parts. First there is the base system, or main operating system. This is the part which consists of the kernel and basis functions and programs (/usr/bin, /bin, /usr/sbin, /etc, and so on). Everything you install "on top", normally by using the ports collection, ends up in /usr/local and no where else. These are also the only programs which end up in the package management system.

But as said; what I was referring to was re-installing these ports (for example by using `# make deinstall` in the mail/dovecot port directory), (re)moving any left over configuration files and then start over using `# make install clean`.

However, when I first commented I overlooked that you were following a tutorial of some sort. And being completely unfamiliar with that tutorial myself I obviously can't determine at which point things started to fail. It's also what triggered my surprise to see Dovecot use the Postfix credentials.

So I'm afraid I can't be of much help on that end.


----------



## studyete (Jun 30, 2013)

_I am s_till unable to connect _to the_ database after reconfiguring _D_ovecot, _M_y_SQL_ and _P_ostfix again. _I'm g_etting _the_ same error as above. _I t_ried to follow below link but _it_ did not work. 

http://wiki.dovecot.org/MysqlProblems

Any suggestion?


----------



## gkontos (Jun 30, 2013)

The is only one line that needs to be configured in dovecot-db.conf


```
connect = host=localhost dbname=postfix user=postfix password=*******
```

If you can't connect  with the correct values then probably you did not build dovecot with mysql support.


----------



## studyete (Jun 30, 2013)

I believe the issue was related to my password syntax. I used # in my password and when I change it at dovecot-db.conf I end up with the following error. Is there any other simpler way other than MySQL. @gkontos would you be kind to see the following error please? 


```
Jun 30 15:43:58 mail dovecot: Dovecot v1.2.17 starting up
Jun 30 15:43:58 mail dovecot: auth-worker(default): mysql: Connected to localhost (postfix)
Jun 30 15:44:32 mail dovecot: dovecot: User postmaster@examples.info not allowed to log in using too low primary UNIX group ID 125(postfix) (see first_valid_gid in config file)
Jun 30 15:44:32 mail dovecot: pop3-login: Internal login failure (auth failed, 1 attempts): user=<postmaster@examples.info>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
```


----------



## gkontos (Jun 30, 2013)

http://wiki.dovecot.org/MainConfig#Mail_processes

Adjust the first_valid_uid and first_valid_gid values.

Everything you need is very well documented in the guide that you are using.


----------



## studyete (Jul 1, 2013)

All set and resolved. thanks @gkontos and @ShelLuser for your contribution. But one last problem I'm facing sending mail and there is no log about the error. I am just getting following error in Outlook or from _the_ command line when *I* try to send mail. 


```
451 4.3.0 <***@gmail.com>: Temporary lookup failure
tahnan@gmail.com... Deferred: 451 4.3.0 <***@gmail.com>: Temporary lookup failure
554 5.5.1 Error: no valid recipients
```


----------



## ShelLuser (Jul 1, 2013)

studyete said:
			
		

> I am just getting following error in Outlook or from _the_ command line when *I* try to send mail.


That almost looks as if that server can't resolve. What happens if you try to run `dig google.com mx`?

Anything specific in /etc/resolv.conf?


----------



## studyete (Jul 1, 2013)

I have only my DNS _IP_ address at /etc/resolv.conf. Nothing else. However, I'm getting lots of warning_s_ when starting Postfix and don't know i I should be worried about that. I am not asking to look over it but if you have the time, please check. Though my Postfix is getting start_ed_.


```
root@mail:/usr/ports/mail/postfix # /usr/local/etc/rc.d/postfix start
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "tuaha-alwatiq.com"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "virtual_alias_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "virtual_alias_domains"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "virtual_mailbox_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "virtual_mailbox_domains"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "relay_recipient_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "relay_domains"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "canonical_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "sender_canonical_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "recipient_canonical_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "relocated_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "transport_maps"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "mynetworks"
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: " "
/usr/local/sbin/postconf: warning: unreasonable macro call nesting: "virtual_mailbox_limit_maps"
/usr/local/sbin/postconf: warning: /usr/local/etc/postfix/main.cf: unused parameter: virtual_create_maildirsize=yes
/usr/local/sbin/postconf: warning: /usr/local/etc/postfix/main.cf: unused parameter: virtual_mailbox_extended=yes
```


----------



## studyete (Jul 3, 2013)

`dig google.com mx` _is_ resolving _G_oogle's _MX_ records but the error _I_'m getting remain_s_ _the_ same. *A*ny suggestion please?


----------



## studyete (Jul 7, 2013)

My maillog provid_es_ _the_ following error from where *I* am getting _a_ hint that my _P_ostfix _is_ somewhat unable to connect with _the_ database.

*P*lease any one have any suggestion*.*

```
Jul  7 22:47:14 mail postfix/postfix-script[84933]: starting the Postfix mail system
Jul  7 22:47:14 mail postfix/master[84935]: daemon started -- version 2.10.0, configuration /usr/local/etc/postfix
Jul  7 22:48:19 mail sendmail[84941]: r67GmJ0s084941: from=tahnan, size=36, class=0, nrcpts=1, msgid=<201307071648.r67GmJ0s084941@dispatch.kahuna.glbdns.microsoft.com>, relay=root@localhost
Jul  7 22:48:20 mail postfix/smtpd[84942]: error: open database /etc/aliases.db: No such file or directory
Jul  7 22:48:20 mail postfix/smtpd[84942]: connect from localhost[127.0.0.1]
Jul  7 22:48:20 mail sendmail[84941]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=DHE-RSA-AES256-SHA, bits=256/256
Jul  7 22:48:20 mail postfix/proxymap[84938]: warning: mysql query failed: Table 'postfix.alias' doesn't exist
Jul  7 22:48:20 mail postfix/trivial-rewrite[84944]: warning: proxy:mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf: table lookup problem
Jul  7 22:48:20 mail postfix/trivial-rewrite[84944]: warning: virtual_alias_domains lookup failure
Jul  7 22:48:20 mail postfix/trivial-rewrite[84944]: warning: proxy:mysql:/usr/local/etc/postfix/mysql_virtual_alias_maps.cf: table lookup problem
Jul  7 22:48:20 mail postfix/trivial-rewrite[84944]: warning: virtual_alias_domains lookup failure
Jul  7 22:48:20 mail postfix/smtpd[84942]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 451 4.3.0 <tahnan@gmail.com>: Temporary lookup failure; from=<tahnan@dispatch.kahuna.glbdns.microsoft.com> to=<tahnan@gmail.com> proto=ESMTP helo=<dispatch.kahuna.glbdns.microsoft.com>
Jul  7 22:48:20 mail sendmail[84941]: r67GmJ0s084941: to=tahnan@gmail.com, ctladdr=tahnan (1001/1001), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30036, relay=[127.0.0.1] [127.0.0.1], dsn=4.3.0, stat=Deferred: 451 4.3.0 <tahnan@gmail.com>: Temporary lookup failure
Jul  7 22:48:20 mail postfix/smtpd[84942]: disconnect from localhost[127.0.0.1]
Jul  7 23:07:19 mail postfix/postfix-script[84994]: stopping the Postfix mail system
Jul  7 23:07:19 mail postfix/master[84935]: terminating on signal 15
Jul  7 23:07:29 mail postfix/postfix-script[85070]: starting the Postfix mail system
Jul  7 23:07:29 mail postfix/master[85072]: daemon started -- version 2.10.0, configuration /usr/local/etc/postfix
```


----------



## gkontos (Jul 7, 2013)

How To Ask Questions The Smart Way


----------



## tingo (Jul 8, 2013)

So, what are you going to do with that hint? Are you going to check that the file in the hint exists? Is it bigger than zero bytes? And, what's the next step?


----------

