Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Virtual MailHost Tip: virtual_mailbox_domains in mysql
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
John McBride
n00b
n00b


Joined: 28 Jan 2004
Posts: 6

PostPosted: Tue Feb 03, 2004 3:59 am    Post subject: Virtual MailHost Tip: virtual_mailbox_domains in mysql Reply with quote

First, let me apologize if this information is covered elsewhere; I don't mean to duplicate existing documentation. Second, I'm not a Postfix guru, and for all I know the following might not even be necessary - but it does work for me.

I followed the Virtual MailboxHost Guide (which is excellent), and could recieve mail for my local host (the domain name listed in main.cf), but all my mail to virtual domains bounced, with a "Relay access denied" message. I found a thread in these forums that solved this problem -- basically, I hadn't set the "virtual_mailbox_domains" for each of the domains I wanted the postfix virtual delivery agent to consider itself the final destination for. So, once things were working, my main.cf had the following line:

Code:
virtual_mailbox_domain = virtual.domain.name, another.domain.name, etc.


The thing is, you enter this data into the database as part of the transport table -- why should you have to duplicate it in main.cf? Having to synch two different fields that contain the same data is not always a safe practice; as the number of domains you're hosting grows, it becomes more and more of a problem.

But if change the line to read ...
Code:
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-domains.cf


and create a mysql-virtual-domains.cf file ...
Code:
#/etc/postfix/mysql-virtual-domains.cf
user            = mailsql
password        = $$$YOUR PASSWORD HERE$$$
dbname          = mailsql
table           = transport
select_field    = domain
where_field     = domain
additional_conditions = and destination = "virtual:"
hosts           = unix:/var/run/mysqld/mysqld.sock


... now we're in business. All virtual domains we consider ourselves the final destination for are now stored in a single place - the database.

Just
Code:
#/postfix reload


... and you're done.

Cheers,
John
Back to top
View user's profile Send private message
at6
Tux's lil' helper
Tux's lil' helper


Joined: 28 Nov 2002
Posts: 78
Location: /dev/null

PostPosted: Thu Feb 05, 2004 8:47 pm    Post subject: thnx Reply with quote

hi john,

perfect tutorial. this is just the solution for my problem. small effort, great effect!
just one little suggestion:

can you post the database scheme? perhabst as an .sql file?

thanks ;)

best regards

marc
_________________
debian: stable but lame! suse: unstable and lame! gentoo: stable and only 4 geeks!
Gadget tests!
Back to top
View user's profile Send private message
John McBride
n00b
n00b


Joined: 28 Jan 2004
Posts: 6

PostPosted: Fri Feb 06, 2004 4:03 am    Post subject: Reply with quote

I used the schema given in the Virtual/MailHost Tutorial (http://www.gentoo.org/doc/en/virt-mail-howto.xml) on the Gentoo site. The schema given there is: http://kickasskungfu.com/~ken/genericmailsql.sql.

Did you set up your mail system using the Virtual/MailHost Tutorial? If so, you should already have the proper schema.

If you didn't use the MailHost tutorial and don't have that schema, don't worry - provided you've got MySQL, you could use:
Code:
mysql> DROP TABLE IF EXISTS virtual_mailbox;
CREATE TABLE virtual_mailbox (
  id int(11) NOT NULL auto_increment,
  domain varchar(128) NOT NULL,
  PRIMARY KEY  (id),
  UNIQUE KEY domain (domain)
) TYPE=MyISAM;


insert your domain names into this fields:

Code:
mysql> insert into virtual_mailbox (domain) values ('DOMAIN.NAME')


then change your postfix main.cf:

Code:
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-domains.cf


then create that file:
Code:
#/etc/postfix/mysql-virtual-domains.cf
user            = mailsql
password        = $$$YOUR PASSWORD HERE$$$
dbname          = mailsql
table           = virtual_mailbox
select_field    = domain
where_field     = domain
hosts           = unix:/var/run/mysqld/mysqld.sock


If that doesn't work for you, let me know, and we'll try something else.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum