[Dovecot] Recipient delimiters, deliver and SQL databases
Hi!
As a new user, I'm trying to set up a postfix + dovecot combination, and so far all is running smoothly. I'm using the guidelines that came with postfix and adjusting them as I go.
My user and alias database is stored in MySQL, using the scheme from 'PostfixAdmin' (http://high5.net/page9.html) and I am using the dovecot LDA 'deliver' to drop messages into mailboxes that exist solely as virtual users.
Users can login using both pop3 and imap, and retrieve the e-mails sent directly to them, so I'm happy with that.
One of the features supported by postfix, and required for my setup is recipient delimiters. Using recipient delimiters, you can basically send extra information in the e-mail address, to maybe deliver the message into subfolders directly, or to run anti-spam software such as TMDA against.
When I try to deliver such a message, I get a user unknown:
Dec 9 14:25:01 vm-mail postfix/pickup[91477]: 4574A6420: uid=0 from=<root>
Dec 9 14:25:01 vm-mail postfix/cleanup[91487]: 4574A6420:
message-id=20061209142501.4574A6420@vm-mail.mydomain
Dec 9 14:25:01 vm-mail postfix/qmgr[91478]: 4574A6420:
from=root@vm-mail.mydomain, size=290, nrcpt=1 (queue active)
Dec 9 14:25:01 vm-mail dovecot: auth(default): master in: USER 1
user+test@mydomain service=deliver
Dec 9 14:25:01 vm-mail dovecot: auth-worker(default):
sql(user+test@mydomain): SELECT maildir, 143 AS uid, 143 AS gid FROM
mailbox WHERE username = 'user+test@mydomain' AND active = '1'
Dec 9 14:25:01 vm-mail dovecot: auth-worker(default):
sql(user+test@mydomain): User not found
Dec 9 14:25:01 vm-mail dovecot: auth(default): master out: NOTFOUND 1
Dec 9 14:25:01 vm-mail postfix/pipe[91489]: 4574A6420:
to=user+test@mydomain, relay=dovecot, delay=0.14,
delays=0.07/0.03/0/0.04, dsn=5.1.1, status=bounced (user unknown)
Relevant snippets from postfix's master.cf:
# Dovecot LDA dovecot unix - n n - - pipe flags=DRhu user=dovecot:dovecot argv=/usr/local/libexec/dovecot/deliver -d ${recipient}
and postfix's main.cf:
virtual_gid_maps = static:143 virtual_mailbox_base = /mail/virtual virtual_minimum_uid = 125 dovecot_destination_recipient_limit = 1 virtual_transport = dovecot virtual_uid_maps = static:143
and dovecot's dovecot.conf:
protocol lda { postmaster_address = postmaster@mydomain sendmail_path = /usr/sbin/sendmail auth_socket_path = /var/run/dovecot-auth-master }
auth default {
passdb sql { args = /usr/local/etc/dovecot-mysql.conf }
userdb sql { args = /usr/local/etc/dovecot-mysql.conf }
socket listen { client { path = /var/spool/postfix/private/auth mode = 0660 user = postfix group = postfix }
master {
path = /var/run/dovecot-auth-master
mode = 0600
user = dovecot
group = dovecot
}
} }
And offcourse dovecot-mysql.conf:
# Database driver: mysql, pgsql driver = mysql
# Currently supported schemes include PLAIN, PLAIN-MD5, DIGEST-MD5, and CRYPT. default_pass_scheme = CRYPT
# Database options connect = host=myhost dbname=mydb user=myuser password=mypass
password_query = SELECT password FROM mailbox WHERE username = '%u' AND active = '1' user_query = SELECT maildir, 143 AS uid, 143 AS gid FROM mailbox WHERE username = '%u' AND active = '1' #EOF
Now, I am pretty sure the problem lies with the %u, expanding to user+test@mydomain, which in some way should become user@mydomain, since the latter is the actual mailbox name of the user, but: how?
Thanks in advance,
Nils
-- Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one.
~Benjamin Franklin (American Statesman, Scientist, Philosopher, Printer, Writer and Inventor. 1706-1790)
On Sat, 09 Dec 2006 17:56:20 +0100 Nils Vogels nivo+sender+9bb457@is-root.com wrote:
One of the features supported by postfix, and required for my setup is recipient delimiters. Using recipient delimiters, you can basically send extra information in the e-mail address, to maybe deliver the message into subfolders directly, or to run anti-spam software such as TMDA against.
Side note: if you use TMDA with what I refer to as the Challenge Response Authentication Protocol, you are a source of spam. Sending responses to users who did not send the original message is backscatter, and will get you blocked. No one wants to deal with your CRAP.
When I try to deliver such a message, I get a user unknown: [snip] Now, I am pretty sure the problem lies with the %u, expanding to user+test@mydomain, which in some way should become user@mydomain, since the latter is the actual mailbox name of the user, but: how?
Check the postfix setting recipient_delimiter.
-- Marshal Newrock Ideal Solution, LLC - http://www.idealso.com
Marshal Newrock wrote on 9-12-2006 19:05:
On Sat, 09 Dec 2006 17:56:20 +0100 Nils Vogels nivo+sender+9bb457@is-root.com wrote:
One of the features supported by postfix, and required for my setup is recipient delimiters. Using recipient delimiters, you can basically send extra information in the e-mail address, to maybe deliver the message into subfolders directly, or to run anti-spam software such as TMDA against.
Side note: if you use TMDA with what I refer to as the Challenge Response Authentication Protocol, you are a source of spam. Sending responses to users who did not send the original message is backscatter, and will get you blocked. No one wants to deal with your CRAP.
That is a matter of configuring the product to behave sanely, but indeed, totally not what my question was about :-)
When I try to deliver such a message, I get a user unknown:
[snip]
Now, I am pretty sure the problem lies with the %u, expanding to user+test@mydomain, which in some way should become user@mydomain, since the latter is the actual mailbox name of the user, but: how?
Check the postfix setting recipient_delimiter.
vm-mail# postconf recipient_delimiter recipient_delimiter = + vm-mail# postfix reload postfix/postfix-script: refreshing the Postfix mail system vm-mail# echo "Test8" | mail user+test@mydomain .. results in a bounce, since user+test@mydomain is not a valid mailbox name, user@mydomain is.
Is there any macro (such as %u) that expands to *JUST* the local user part of an e-mail address ?
Greets,
Nils
-- Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one.
~Benjamin Franklin (American Statesman, Scientist, Philosopher, Printer, Writer and Inventor. 1706-1790)
On Sat, 09 Dec 2006 20:11:19 +0100 Nils Vogels nivo@is-root.com wrote:
Now, I am pretty sure the problem lies with the %u, expanding to user+test@mydomain, which in some way should become user@mydomain, since the latter is the actual mailbox name of the user, but: how?
Check the postfix setting recipient_delimiter.
vm-mail# postconf recipient_delimiter recipient_delimiter = + vm-mail# postfix reload postfix/postfix-script: refreshing the Postfix mail system vm-mail# echo "Test8" | mail user+test@mydomain .. results in a bounce, since user+test@mydomain is not a valid mailbox name, user@mydomain is.
Is there any macro (such as %u) that expands to *JUST* the local user part of an e-mail address ?
In my system, there is a file called variables.txt in /usr/share/doc/dovecot. %n should just be the user part, as %d is the domain part, so "%n@%d" would still be the full email address. If %n would still be "user+test" (I don't know if this is the case) then perhaps there should be an additional modifier which strips out everything between a certain character and @. Meanwhile, it's possible to simulate this in the query. In MySQL, the query would be something like "WHERE email=CONCAT(SUBSTRING_INDEX('%u', '+', 1), '@', '%d')"
-- Marshal Newrock Ideal Solution, LLC - http://www.idealso.com
Marshal Newrock wrote on 10-12-2006 9:20:
On Sat, 09 Dec 2006 20:11:19 +0100 Nils Vogels nivo@is-root.com wrote:
Now, I am pretty sure the problem lies with the %u, expanding to user+test@mydomain, which in some way should become user@mydomain, since the latter is the actual mailbox name of the user, but: how?
Check the postfix setting recipient_delimiter.
vm-mail# postconf recipient_delimiter recipient_delimiter = + vm-mail# postfix reload postfix/postfix-script: refreshing the Postfix mail system vm-mail# echo "Test8" | mail user+test@mydomain .. results in a bounce, since user+test@mydomain is not a valid mailbox name, user@mydomain is.
Is there any macro (such as %u) that expands to *JUST* the local user part of an e-mail address ?
In my system, there is a file called variables.txt in /usr/share/doc/dovecot. %n should just be the user part, as %d is the domain part, so "%n@%d" would still be the full email address. If %n would still be "user+test" (I don't know if this is the case) then perhaps there should be an additional modifier which strips out everything between a certain character and @. Meanwhile, it's possible to simulate this in the query. In MySQL, the query would be something like "WHERE email=CONCAT(SUBSTRING_INDEX('%u', '+', 1), '@', '%d')"
%n is 'user+test; in my testcase, and not 'user' as I would like it to be. Would it be possible to add a variable to dovecot that only gives me the local user part, because indeed that should solve the problem.
Probably, also a configuration item needs to be added, to make deliver aware of the character that was chosen as recipient delimiter, since the '+' maybe standard for postfix, but other choices could be made as well.
On a side note: the SQL query from Marshal only works if there is a recipient delimiter present, if it is not, it adds the domain name to the e-mail address being looked up, causing all kinds of other problems. I haven't found a SQL query to mimic the desired deliver behaviour in this case yet.
Greetings,
Nils
-- Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one.
~Benjamin Franklin (American Statesman, Scientist, Philosopher, Printer, Writer and Inventor. 1706-1790)
On Tue, 12 Dec 2006 00:19:12 +0100 Nils Vogels nivo+sender+9bb457@is-root.com wrote:
On a side note: the SQL query from Marshal only works if there is a recipient delimiter present, if it is not, it adds the domain name to the e-mail address being looked up, causing all kinds of other problems. I haven't found a SQL query to mimic the desired deliver behaviour in this case yet.
I'm not sure what your data looks like. If you can give a couple of samples (with delimiter and without, including what's in the database), I can probably cook up a good query for you. It might require an IF().
-- Marshal Newrock, Ideal Solution LLC http://www.idealso.com
Marshal Newrock wrote on 12-12-2006 0:28:
On Tue, 12 Dec 2006 00:19:12 +0100 Nils Vogels nivo+sender+9bb457@is-root.com wrote:
On a side note: the SQL query from Marshal only works if there is a recipient delimiter present, if it is not, it adds the domain name to the e-mail address being looked up, causing all kinds of other problems. I haven't found a SQL query to mimic the desired deliver behaviour in this case yet.
I'm not sure what your data looks like. If you can give a couple of samples (with delimiter and without, including what's in the database), I can probably cook up a good query for you. It might require an IF().
Thanks for all your help so far. I've come to the conclusion that when I don't use dovecot's deliver but use postfix's own LDA instead, all works as expected.
Right now I'll be focussing on that, and possibly maildrop should it ever be needed to do some additional custom filtering, as long as deliver doesn't have built-in recognition for recipient delimiters.
Greetings & thanks for your time,
Nils.
-- Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one.
~Benjamin Franklin (American Statesman, Scientist, Philosopher, Printer, Writer and Inventor. 1706-1790)
Now, I am pretty sure the problem lies with the %u, expanding to user+test@mydomain, which in some way should become user@mydomain, since the latter is the actual mailbox name of the user, but: how?
I think it would be nice if deliver took a -e ${extension} but for now I use this in Postfix:
dovecot unix - n n - 10 pipe flags=DORhu user=vuser argv=/usr/local/libexec/dovecot/deliver -d ${user}@${nexthop}
My sieve scripts, of course, don't know about the extension so I have to filter accordingly.
Jim
participants (3)
-
Jim Horner
-
Marshal Newrock
-
Nils Vogels