# Postfix, Courier-IMAP, MySQL and FreeBSD



## peep96 (Nov 18, 2010)

Hey guys,

Trying to set up a mail server using Postfix, Courier IMAP and MySQL for virtual domains/users on FreeBSD. So far, no luck. Here's my config file and my logs, let me know if you can make anything of it. I'm new to Postfix and am researching it still. Thanks in advance.


```
soft_bounce = no
queue_directory = /var/spool/postfix
command_directory = /usr/local/sbin
daemon_directory = /usr/local/libexec/postfix
mail_owner = postfix
default_privs = nobody

myhostname = (my hostname is here)
inet_interfaces = all
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8
mail_spool_directory = /var/home/mail
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/local/sbin/sendmail
html_directory = no
manpage_directory = /usr/local/man
sample_directory = /usr/local/etc/postfix
setgid_group = maildrop
readme_directory = no
alias_database = mysql:/usr/local/etc/postfix/mysql/virtual_alias_maps.cf
alias_maps = mysql:/usr/local/etc/postfix/mysql/virtual_alias_maps.cf
virtual_mailbox_limit = 0
mailbox_size_limit=0
message_size_limit = 102400000

#sasl
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_application_name=smtpd
smtpd_sasl_security_options = noanonymous
smtpd_helo_required = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_invalid_hostname,
reject_non_fqdn_hostname,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_sender_domain,
reject_unknown_recipient_domain,reject_unauth_destination,permit
#virtual
virtual_uid_maps = static:125
virtual_gid_maps = static:125
virtual_transport = virtual
virtual_alias_maps = mysql:/usr/local/etc/postfix/mysql/virtual_alias_maps.cf
transport_maps=mysql:/usr/local/etc/postfix/mysql/transport.cf
virtual_mailbox_base=/var/home/mail
virtual_mailbox_maps=mysql:/usr/local/etc/postfix/mysql/users.cf
mydestination = $mydomain, $myhostname, $transport_maps

#set local recipient maps
local_recipient_maps = $virtual_mailbox_maps
smtpd_sender_login_maps=mysql:/usr/local/etc/postfix/mysql/sender_check.cf
smtpd_sender_restrictions=reject_sender_login_mismatch, permit_sasl_authenticated
```

my /var/log/messages 


```
Nov 18 01:42:14 web1 postfix/smtpd[38505]: fatal: no SASL authentication mechanisms
Nov 18 01:43:15 web1 postfix/smtpd[38510]: fatal: no SASL authentication mechanisms
Nov 18 01:43:15 web1 postfix/smtpd[38506]: fatal: no SASL authentication mechanisms
Nov 18 01:43:15 web1 postfix/smtpd[38509]: fatal: no SASL authentication mechanisms
Nov 18 01:43:15 web1 postfix/smtpd[38508]: fatal: no SASL authentication mechanisms
Nov 18 01:43:15 web1 postfix/smtpd[38507]: fatal: no SASL authentication mechanisms
Nov 18 01:44:17 web1 postfix/smtpd[38538]: fatal: no SASL authentication mechanisms
Nov 18 01:44:17 web1 postfix/smtpd[38536]: fatal: no SASL authentication mechanisms
Nov 18 01:44:17 web1 postfix/smtpd[38537]: fatal: no SASL authentication mechanisms
Nov 18 01:45:18 web1 postfix/smtpd[38544]: fatal: no SASL authentication mechanisms
Nov 18 01:45:18 web1 postfix/smtpd[38545]: fatal: no SASL authentication mechanisms
Nov 18 01:46:19 web1 postfix/smtpd[38549]: fatal: no SASL authentication mechanisms
Nov 18 01:46:19 web1 postfix/smtpd[38551]: fatal: no SASL authentication mechanisms
Nov 18 01:46:20 web1 postfix/smtpd[38550]: fatal: no SASL authentication mechanisms
Nov 18 01:46:20 web1 postfix/smtpd[38548]: fatal: no SASL authentication mechanisms
Nov 18 01:46:20 web1 postfix/smtpd[38547]: fatal: no SASL authentication mechanisms
Nov 18 01:47:20 web1 postfix/smtpd[38571]: fatal: no SASL authentication mechanisms
Nov 18 01:53:35 web1 login: chflags(/dev/pts/0): No such file or directory
Nov 18 01:53:35 web1 login: chown(/dev/pts/0): No such file or directory
Nov 18 02:00:18 web1 postfix/smtpd[39543]: fatal: no SASL authentication mechanisms
```

my /var/log/maillog


```
Nov 18 01:59:32 web1 postfix/postqueue[39360]: warning: Mail system is down -- accessing queue directly
Nov 18 01:59:41 web1 postfix/postfix-script[39432]: starting the Postfix mail system
Nov 18 01:59:41 web1 postfix/master[39433]: daemon started -- version 2.7.1, configuration /usr/local/etc/postfix
Nov 18 02:00:17 web1 postfix/smtpd[39543]: warning: when SASL type is "dovecot", SASL path "smtpd" should be a socket pathname
Nov 18 02:00:18 web1 postfix/smtpd[39543]: connect from unknown[121.8.146.179]
Nov 18 02:00:18 web1 postfix/smtpd[39543]: warning: SASL: Connect to smtpd failed: No such file or directory
Nov 18 02:00:18 web1 postfix/smtpd[39543]: fatal: no SASL authentication mechanisms
Nov 18 02:00:19 web1 postfix/master[39433]: warning: process /usr/local/libexec/postfix/smtpd pid 39543 exit status 1
Nov 18 02:00:19 web1 postfix/master[39433]: warning: /usr/local/libexec/postfix/smtpd: bad command startup -- throttling
Nov 18 02:01:19 web1 postfix/smtpd[39563]: warning: when SASL type is "dovecot", SASL path "smtpd" should be a socket pathname
Nov 18 02:01:19 web1 postfix/smtpd[39563]: connect from unknown[124.65.50.10]
Nov 18 02:01:19 web1 postfix/smtpd[39563]: warning: SASL: Connect to smtpd failed: No such file or directory
Nov 18 02:01:19 web1 postfix/smtpd[39563]: fatal: no SASL authentication mechanisms
Nov 18 02:01:20 web1 postfix/master[39433]: warning: process /usr/local/libexec/postfix/smtpd pid 39563 exit status 1
Nov 18 02:01:20 web1 postfix/master[39433]: warning: /usr/local/libexec/postfix/smtpd: bad command startup -- throttling
```


----------



## graudeejs (Nov 18, 2010)

```
Nov 18 02:00:17 web1 postfix/smtpd[39543]: warning: when SASL type is "dovecot", SASL path "smtpd" should be a socket pathname
```

to main.cf add

```
smtpd_sasl_path = /var/run/dovecot/auth-client
```

and check that in dovecot.conf you have

```
client {
      path = /var/run/dovecot/auth-client
      mode = 0660
        user = postfix
        group = mail
    }
```

Also check out
http://forums.freebsd.org/showthread.php?t=10728

it might shed some light
At the end of howto there are resource. there is one resource regarding postfix & mysql.... probably useful to you as well


----------



## peep96 (Nov 18, 2010)

Thank you for the reply.

Actually, I am not using Dovecot. I was trying to set it up using this tutorial:

http://www.freebsdonline.com/content/view/339/348/

Would it just be easier to switch to dovecot? And what would I have to modify in order for Dovecot to work with what I have done already?


----------



## graudeejs (Nov 18, 2010)

I dunno, I only use dovecot... I like that it has Sieve support, that's a big plus. (You can write simple script to move mail to Spam).

I don't know if Courier-IMAP supports it

check if you haven't set:

```
virtual_transport = dovecot
smtpd_sasl_type = dovecot
```
somehere (main.cf, master.cf)

I suggest you read this tutorial:
http://www.purplehat.org/?page_id=4

It helped me a lot configuring my first mail server (I used PostgreSQL)


----------



## hockey97 (Aug 30, 2011)

What is Dovecot? I am not too setting up my own mail server. Would like to know what is Dovecot. I googled around. I know it's a secure Imap server. I would like someone to give me a simple explanation of what it does. Like the purpose of it.


----------



## AndyUKG (Aug 30, 2011)

Dovecot, description and more is here at the homepage:

http://www.dovecot.org/

Basically it provides IMAP and POP3 support so its an alternative to Courier in your config...

Andy.


----------

