-   Linux - Server (
-   -   postfix/dovecot issues (

daled 08-18-2010 08:01 PM

postfix/dovecot issues
I'm a newbie to linux trying to setup postfix on my ubuntu box to work with my website.

I followed the setup procedure at Now when i test the server using telnet i run into problems. Here's what i'm running:


telnet 25
Connected to
Escape character is '^]'.
220 ESMTP Postfix

But then telnet just hangs and i don't get a 250 response. Anybody know what the problem/solution could be? below is my


# See /usr/share/postfix/ for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname =
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
myorigin =
mydestination =
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

virtual_mailbox_base = /var/spool/mail/virtual
virtual_mailbox_maps = mysql:/etc/postfix/
virtual_alias_maps = mysql:/etc/postfix/
virtual_mailbox_domains = mysql:/etc/postfix/
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

Thanks in advance for all of your help.

jamrock 08-18-2010 08:12 PM

I would recommend using the following documents.

You will not need the first if you are using the version that comes with Ubuntu.

It is best to make as few changes as possible in the beginning. This will help you understand how Postfix works.

Once you have the basic Postfix working with local accounts, you can try using it with virtual accounts.

When you have that working, you can add ssl.

daled 08-21-2010 08:20 PM

Thanks much. I was able to figure out what needed to be fixed. In the mysql files, host=localhost needed to be changed to host=

But now i'm running into more issues. when i telnet in, or send mail to the server otherwise, i put in the recipient as but postfix changes this.

Looking at the logs i see that "orig_to" is but then "to" is either address/ or someotheraddress/ and then that postfix can't find the "to" mailbox.


jamrock 08-22-2010 07:22 AM

Take a look at the following files:

virtual_mailbox_maps = mysql:/etc/postfix/
virtual_alias_maps = mysql:/etc/postfix/

Are you using the Maildir mailbox format? The Maildir format requires a / at the end. This is normally done by adding / to the user name during the search.

For example, with ldap the virtual_mailbox_maps file will look like:

server_host = ldap://
version = 3
search_base = cn=users,dc=testcompay,dc=com
query_filter = (&(mail=%s) (objectClass=user))
result_attribute = samaccountname
result_format = %s/
bind_dn = postfix
bind_pw = DFD321

The result format adds / to the user account.

On the other hand, the virtual_alias_maps file will look like this:

server_host = ldap://
version = 3
search_base = cn=users,dc=testcompay,dc=com
query_filter = (&(mail=%s) (objectClass=user))
result_attribute = samaccountname
bind_dn = postfix
bind_pw = DFD321

There is no result format.

daled 08-22-2010 08:39 AM

Wow, my files look nothing like that. Instead i've got


# /etc/postfix/

additional_conditions = and enabled = 1


# /etc/postfix/

additional_conditions = and enabled = 1

jamrock 08-22-2010 09:10 AM

The differences between my files and yours are not so shocking. I use ldap for virtual users and you use MySQL. The same principles are common to both formats.

/etc/postfix/ tells Postfix the mailbox in which the mail must be stored.

/etc/postfix/ tells Postfix the user to whom the mail must be addressed.

You have select_field=maildir in both files. I don't think this is correct. The format for the maildir value is "username/. If the user name is daled, the maildir (mailbox) value will be daled/.

select_field=maildir should work for /etc/postfix/ since this file shows mailbox information.

Is there another field such as user or username that you can use in the /etc/postfix/ This file shows the username to whom the mail should be addressed.


Looking at the logs i see that "orig_to" is but then "to" is either address/ or someotheraddress/ and then that postfix can't find the "to" mailbox.
The mail is being sent to address/ instead of because you are using the maildir field in /etc/postfix/

daled 08-22-2010 11:11 AM

Thanks much jamrock! That really helped and now postfix doesn't bounce back the incoming email! now to get dovecot imap authentication working to actually view the mail...

daled 08-23-2010 09:29 PM

Alright, so I've finally gotten dovecot IMAP authentication working. The only problem now is that when i try to read the mail in the inbox, it's not there!

When i send the message (via telnet) the mail log reports:

Aug 23 22:24:54 linux9 postfix/smtpd[4336]: connect from localhost[]
Aug 23 22:25:25 linux9 postfix/smtpd[4336]: 536A146972: client=localhost[]
Aug 23 22:25:29 linux9 postfix/cleanup[4340]: 536A146972: message-id=<>
Aug 23 22:25:29 linux9 postfix/qmgr[3831]: 536A146972: from=<*externaluser*>, size=368, nrcpt=1 (queue active)
Aug 23 22:25:29 linux9 postfix/virtual[4341]: 536A146972: to=<*virtualuser*>, relay=virtual, delay=24, delays=24/0.01/0/0.06, dsn=2.0.0, status=sent (delivered to mailbox)
Aug 23 22:25:29 linux9 postfix/qmgr[3831]: 536A146972: removed
Aug 23 22:25:32 linux9 postfix/smtpd[4336]: disconnect from localhost[]

As far as i can see, the mail is successfully delivered, but this is returned from dovecot (via telnet):

1 OK Logged in.
. examine INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS ()] Read-only mailbox.
* OK [UIDVALIDITY 1282615847] UIDs valid
* OK [UIDNEXT 1] Predicted next UID
. OK [READ-ONLY] Select completed.

Any thoughts?

jamrock 08-24-2010 05:26 AM

I use Dovecot for POP3 not IMAP. Not sure how much of a difference this will make.

I see the following line in your
virtual_mailbox_base = /var/spool/mail/virtual

The mailboxes should therefore be created in sub directories below this. You should see the username and below that the new, cur and tmp directories.

New mail should be placed in the directory called new. Do you see the mail there? You can use the ll or ls commands to check.

In your dovecot.conf file you should have the following line:
mail_location = maildir:/var/spool/mail/virtual/%u

This tells Dovecot where to look for the mail. Is it pointing to the correct location?

daled 08-24-2010 07:22 PM

jamrock, youre the best. I changed the setting in the dovecot.conf and also noticed that my postfix query to get the mailbox for a user didn't get the directory but the user's email address, which wasn't right. It works now and I can view the emails on my client! thanks so much!

All times are GMT -5. The time now is 10:10 AM.