Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: DBMail: users

Exporting users from DBMail to Postfix lookup table

 

 

DBMail users RSS feed   Index | Next | Previous | View Threaded


lists.hzfw4 at liquidbytes

May 11, 2008, 7:42 AM

Post #1 of 9 (256 views)
Permalink
Exporting users from DBMail to Postfix lookup table

Hi there,

I'm pretty sure there are other solutions to create lookup tables for
Postfix as well, but want to share my script with the community anyways:

http://www.nulldevice.de/2008/05/exporting-users-from-dbmail-to-postfix-lookup-table/

The good thing is, that it's pretty simple and in use for over a year
now. Works great.

A questions to the dbmail experts on this list: Would there be any other
options than a cron script like this? I think I can remember a way for
Postfix to access MySQL directly, but this might be slow plus you need
compiled-in MySQL support (the Postfix version that comes with Fedora 6
does not have this).

Cheers,
Michael
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


josh at worldhosting

May 11, 2008, 3:17 PM

Post #2 of 9 (243 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

Hi Michael,

Accessing MySQL directly isn't slow, possibly slower than a lookup
table, however the email will eventually need to be inserted into the
database, so a simple select is nothing in comparison.

Here is the snippets of my config to get this going. Note that I have
used my own aliases table, as I found that when using the dbmail
aliases, dbmail was doing the aliases as well as postfix (so double-up
of mail), and for the spam scanner (dspam) to work as I want we need the
emails going out of postfix to the appropriate mailboxes.

If you don't want the aliases to be handled by postfix, just use the
mysql-mailboxes line. You might have to change the query to include the
aliases.

/etc/postfix/main.cf

virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-mailboxes.cf
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-aliases.cf

/etc/postfix/mysql-domains.cf

#
# mysql config file for virtual mailbox lookups
#

hosts = mysqlhost

# The user name and password to log into the mysql server.
user = dbmail
password = XXXXX

# The database name on the servers.
dbname = dbmail

query = SELECT domain FROM domains WHERE domain='%s'

/etc/postfix/mysql-mailboxes.cf

#
# mysql config file for virtual mailbox lookups
#

hosts = mysqlhost

# The user name and password to log into the mysql server.
user = dbmail
password = XXXXX

# The database name on the servers.
dbname = dbmail

query = SELECT userid FROM dbmail_users WHERE userid='%s'

/etc/postfix/mysql-aliases.cf

#
# mysql config file for virtual mailbox lookups
#

hosts = mysqlhost

# The user name and password to log into the mysql server.
user = dbmail
password = XXXXX

# The database name on the servers.
dbname = dbmail

query = select deliverto from forwards WHERE lower(origto) = lower('%s');

Additional schema to handle multiple domains and postfix-side
aliases/forwards:

CREATE TABLE `domains` (
`domain` varchar(100) NOT NULL,
PRIMARY KEY (`domain`)
) ENGINE=InnoDB;

CREATE TABLE `forwards` (

`id` int(11) NOT NULL auto_increment,
`origto` varchar(100) NOT NULL,
`deliverto` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `origto` (`origto`,`deliverto`),
KEY `email` (`origto`)
) ENGINE=InnoDB;



Michael Mayer wrote:
> A questions to the dbmail experts on this list: Would there be any
> other options than a cron script like this? I think I can remember a
> way for Postfix to access MySQL directly, but this might be slow plus
> you need compiled-in MySQL support (the Postfix version that comes
> with Fedora 6 does not have this).

_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


aleksander at krediidiinfo

May 11, 2008, 4:36 PM

Post #3 of 9 (242 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

Michael Mayer wrote:

> I think I can remember a way for
> Postfix to access MySQL directly, but this might be slow plus you need
> compiled-in MySQL support (the Postfix version that comes with Fedora 6
> does not have this).

It's fast enough. If you need postfx-mysql, download and install the
Fedora postfix srpm and look into the spec file. You should find an
option to enable building the postfix-mysql package, if it ain't enabled
already.

If there is no option, you can manually add the mysql options to the
configure or gcc line or whereever it went. I've done this for various
Fedora and Suse (SLES) distro versions.

After building you'll get a postfix-mysql package which you can then
install. So you won't have to replace your installed postfix package.

I am using postfix with mysql support on F6 right now, I remember making
the postfix-mysql package was trivial for F6.


As for the postfix configuration, it looks like this for me, I'm pretty
sure I found it in the dbmail README or wiki.

mail:/etc/postfix # grep local_recipient_maps main.cf
local_recipient_maps = mysql:/etc/postfix/sql-recipients.cf

mail:/etc/postfix # cat sql-recipients.cf
user = dbmail
password = ubersecretpassword
hosts = 127.0.0.1
dbname = dbmail
table = dbmail_aliases
select_field = alias
where_field = alias

And don't forget to create the .db file with "postmap sql-recipients.cf".

HTH,

--
Aleksander Kamenik
System Administrator
Krediidiinfo AS
an Experian Company
Phone: +372 665 9649
Email: aleksander[at]krediidiinfo.ee

http://www.krediidiinfo.ee/
http://www.experiangroup.com/
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


lists.hzfw4 at liquidbytes

May 11, 2008, 4:53 PM

Post #4 of 9 (240 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

Aleksander Kamenik wrote:
> It's fast enough. If you need postfx-mysql, download and install the
> Fedora postfix srpm and look into the spec file. You should find an
> option to enable building the postfix-mysql package, if it ain't enabled
> already.

Thanks a lot for that hint! I will try to get it working that way. I
think using lookup tables is still the better option for high traffic
servers, because most of the mail you usually get is spam for
not-existing addresses. So you can prevent a database access in 90% of
the cases. For my own server however, it should not make a difference -
we do have just like 10 or 20 mailboxes.

Michael
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


uwe at kiewel-online

May 11, 2008, 11:52 PM

Post #5 of 9 (238 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

My solution:

Aleksander Kamenik schrieb:
> Michael Mayer wrote:
>
>
> mail:/etc/postfix # grep local_recipient_maps main.cf
> local_recipient_maps = mysql:/etc/postfix/sql-recipients.cf
>
> mail:/etc/postfix # cat sql-recipients.cf
> user = dbmail
> password = ubersecretpassword
> hosts = 127.0.0.1
> dbname = dbmail
> table = dbmail_aliases
> select_field = alias
> where_field = alias
>

# The user name and password to log into the mysql server.
user = dbmail
password = XXXXXXX
socket = /var/lib/mysql/mysql.sock

# The database name on the servers.
dbname = dbmail

# For Postfix 2.2 and later The SQL query template.
# See mysql_table(5) for details.
#query = SELECT forw_addr FROM mxaliases WHERE alias='%s' AND status='paid'

query = select alias from dbmail_aliases where alias = '%s' union select
userid from dbmail_users where userid = '%s'



I need to use this SQL query, because in my environment there are
userids the same as the main email addresses.


Thx,
Uwe
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


rabbit+list at rabbit

May 12, 2008, 2:32 AM

Post #6 of 9 (233 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

Aleksander Kamenik wrote:

> <snip>
>
> As for the postfix configuration, it looks like this for me, I'm pretty
> sure I found it in the dbmail README or wiki.
>
> mail:/etc/postfix # grep local_recipient_maps main.cf
> local_recipient_maps = mysql:/etc/postfix/sql-recipients.cf
>
> <snip>

Just FYI - make sure to add proxy: to all your mysql lookups just like Josh
Marshall did here http://www.mail-archive.com/dbmail[at]dbmail.org/msg14781.html
Without this you are risking a DoS attack on your sql server (too many
concurrent connections).
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


aleksander at krediidiinfo

May 12, 2008, 4:13 AM

Post #7 of 9 (233 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

Peter Rabbitson wrote:

> Just FYI - make sure to add proxy: to all your mysql lookups just like
> Josh Marshall did here
> http://www.mail-archive.com/dbmail[at]dbmail.org/msg14781.html Without this
> you are risking a DoS attack on your sql server (too many concurrent
> connections).

Thanks for the hint, will do.

The postfix manual on the subject: http://www.postfix.org/proxymap.8.html

Regards,

--
Aleksander Kamenik
System Administrator
Krediidiinfo AS
an Experian Company
Phone: +372 665 9649
Email: aleksander[at]krediidiinfo.ee

http://www.krediidiinfo.ee/
http://www.experiangroup.com/
_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail


michael.monnerie at it-management

May 12, 2008, 3:21 PM

Post #8 of 9 (221 views)
Permalink
Re: Exporting users from DBMail to Postfix lookup table [In reply to]

On Montag, 12. Mai 2008 Michael Mayer wrote:
> I think using lookup tables is still the better option for high
> traffic servers, because most of the mail you usually get is spam for
> not-existing addresses. So you can prevent a database access in 90%
> of the cases. For my own server however, it should not make a
> difference - we do have just like 10 or 20 mailboxes.

Simply use
address_verify_map = btree:/etc/postfix/verify
address_verify_negative_refresh_time = 3h
address_verify_negative_expire_time = 3d
in main.cf so that postfix caches it's knowledge about recipients in
it's own hash. Fast enough and fully automatic.

mfg zmi
--
// Michael Monnerie, Ing.BSc ----- http://it-management.at
// Tel: 0676/846 914 666 .network.your.ideas.
// PGP Key: "curl -s http://zmi.at/zmi.asc | gpg --import"
// Fingerprint: AC19 F9D5 36ED CD8A EF38 500E CE14 91F7 1C12 09B4
// Keyserver: www.keyserver.net Key-ID: 1C1209B4
Attachments: signature.asc (0.19 KB)


jiipee at sotapeli

May 15, 2008, 2:30 PM

Post #9 of 9 (190 views)
Permalink
RE: Exporting users from DBMail to Postfix lookup table [In reply to]

You could prolly use centos 5 version of postfix what comes with mysql and
pgsql support.
RHEL5 is based to FC6 and centos5 = rhel5

Same time you could upgrade your box to centos5, you know that fc6 is not
supported anymore?


> -----Original Message-----
> From: dbmail-bounces[at]dbmail.org
> [mailto:dbmail-bounces[at]dbmail.org] On Behalf Of Michael Mayer
> Sent: Sunday, May 11, 2008 5:43 PM
> To: dbmail[at]dbmail.org
> Subject: [Dbmail] Exporting users from DBMail to Postfix lookup table
>
> Hi there,
>
> I'm pretty sure there are other solutions to create lookup
> tables for Postfix as well, but want to share my script with
> the community anyways:
>
> http://www.nulldevice.de/2008/05/exporting-users-from-dbmail-t
> o-postfix-lookup-table/
>
> The good thing is, that it's pretty simple and in use for
> over a year now. Works great.
>
> A questions to the dbmail experts on this list: Would there
> be any other options than a cron script like this? I think I
> can remember a way for Postfix to access MySQL directly, but
> this might be slow plus you need compiled-in MySQL support
> (the Postfix version that comes with Fedora 6 does not have this).
>
> Cheers,
> Michael
> _______________________________________________
> DBmail mailing list
> DBmail[at]dbmail.org
> https://mailman.fastxs.nl/mailman/listinfo/dbmail
>
>

_______________________________________________
DBmail mailing list
DBmail[at]dbmail.org
https://mailman.fastxs.nl/mailman/listinfo/dbmail

DBMail users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.