LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   postfix/dovecot issues (http://www.linuxquestions.org/questions/linux-server-73/postfix-dovecot-issues-827107/)

daled 08-18-2010 09: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 http://flurdy.com/docs/postfix/ Now when i test the server using telnet i run into problems. Here's what i'm running:

Code:

telnet fmxstudio.com 25
Trying 71.224.148.228...
Connected to fmxstudio.com.
Escape character is '^]'.
220 fmxstudio.com ESMTP Postfix
HELO something.something.com
250 fmxstudio.com
MAIL FROM:<fmxstudio@gmail.com>

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

Code:

# See /usr/share/postfix/main.cf.dist 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_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
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 = fmxstudio.com
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
myorigin = fmxstudio.com
mydestination =
relayhost = outbound.mailhop.org
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/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/mysql_mailbox.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

Thanks in advance for all of your help.

jamrock 08-18-2010 09:12 PM

I would recommend using the following documents.

http://www.postfix.org/INSTALL.html

http://www.postfix.org/BASIC_CONFIGURATION_README.html

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 09: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=127.0.0.1

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 address@fmxstudio.com but postfix changes this.

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

Explanation?

jamrock 08-22-2010 08:22 AM

Take a look at the following files:

virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf

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://mail.testcompany.com:389
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://mail.testcompany.com:389
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 09:39 AM

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

Code:

# /etc/postfix/mysql_mailbox.cf

user=*****
password=******
dbname=maildb
table=users
select_field=maildir
where_field=id
hosts=127.0.0.1
additional_conditions = and enabled = 1

Code:

# /etc/postfix/mysql_alias.cf

user=****
password=*****
dbname=maildb
table=users
select_field=maildir
where_field=id
hosts=127.0.0.1
additional_conditions = and enabled = 1


jamrock 08-22-2010 10: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/mysql_mailbox.cf tells Postfix the mailbox in which the mail must be stored.

/etc/postfix/mysql_alias.cf 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/mysql_mailbox.cf since this file shows mailbox information.

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

Quote:

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

daled 08-22-2010 12:11 PM

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 10: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:
Code:

Aug 23 22:24:54 linux9 postfix/smtpd[4336]: connect from localhost[127.0.0.1]
Aug 23 22:25:25 linux9 postfix/smtpd[4336]: 536A146972: client=localhost[127.0.0.1]
Aug 23 22:25:29 linux9 postfix/cleanup[4340]: 536A146972: message-id=<20100824022525.536A146972@mail.fmxstudio.com>
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[127.0.0.1]

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

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

Any thoughts?

jamrock 08-24-2010 06: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 main.cf.
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 08: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 03:53 PM.