Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-14-2010, 01:42 PM
|
#1
|
LQ Newbie
Registered: Feb 2008
Location: Pasco, WA
Posts: 2
Rep:
|
Virtual Postfix, mysql, and Virtual Aliases
Hey all, I've got a working Virtual Postfix server running with mysql doing user authentication. I have a support email address set as support@hostname.com, which has 5 aliases associated; user1, user2, user3, user4, and user5. When an email is sent to support@hostname.com, all 5 users receive the email, just as planned. What I'm looking to do is when an email is sent to support@hostname.com to have it rotate through the members of the alias group. That way all members of the group get support emails evenly and not everybody all at once. Is this possible?
Many Thanks ahead of time!
|
|
|
10-15-2010, 07:19 AM
|
#2
|
LQ Newbie
Registered: Nov 2009
Location: Buenos Aires, Argentina
Posts: 23
Rep:
|
Hve almost the same setup, but using dovecot as pop3/imap and lda agent.
Maybe you can try modifying the query that obtains the alias destination when you query the database for support@.. It occurs to me that you might be able to implement some kind of "load-balance" between the destination addresses via SQL, but you would need to mantain account of the last destination address used.
Another solution would be using a shared IMAP folder and send the support emails there, that way each user does know which mails are read and which ones not, but this is slightly different than what you're asking for.
I hope it helps.
Best rgds!
|
|
|
10-15-2010, 10:36 AM
|
#3
|
LQ Newbie
Registered: Feb 2008
Location: Pasco, WA
Posts: 2
Original Poster
Rep:
|
In my mysql_virtual_alias_maps.cf I have the line that reads
query = SELECT username FROM supportemail WHERE support='%s' AND id = '1'
About the closest I've gotten is having the query choose id 1. The one thing that would make this work is either A: Have something that will edit my config file that will rotate between id's 1-5 every time a query is made, or B: Have something that will auto rotate the id numbers 1-5 in the mysql table every time a query is made.
Also, the IMAP idea would work too. I may just propose that idea instead.
|
|
|
10-15-2010, 11:34 PM
|
#4
|
LQ Newbie
Registered: Nov 2009
Location: Buenos Aires, Argentina
Posts: 23
Rep:
|
Maybe something like this (haven't trie so I don't know if it works as is... but the concept is complete):
// query that you put in postfix virtual_domains config file:
SELECT CASE '%s' WHEN 'support@domain.com' THEN getSupportAddress('%s') ELSE goto END FROM alias_table WHERE address = '%s' AND active = 1;
// This mysql function does the hard work for selecting the least recently used destination and updating the database's timestamp
CREATE FUNCTION getSupportAddress (INOUT VARCHAR address) RETURNS varchar
BEGIN
-- select the address that was used least recently
SET @tmp = SELECT goto FROM alias WHERE address = @address ORDER BY last_used LIMIT 1;
-- update that address' timestamp with the current time, to avoid selecting it next time
UPDATE alias SET last_used = NOW() WHERE address = @address;
-- return the alias destination
RETURN @tmp;
END
It has the downside that you have to add an extra column (timestamp) to the aliases table only to keep account of the support alias usage.
Let me know if this is of any help!
Best regards!
German
|
|
|
10-15-2010, 11:36 PM
|
#5
|
LQ Newbie
Registered: Nov 2009
Location: Buenos Aires, Argentina
Posts: 23
Rep:
|
Quote:
Originally Posted by Germanchu
Maybe something like this (haven't trie so I don't know if it works as is... but the concept is complete):
// query that you put in postfix virtual_domains config file:
SELECT CASE '%s' WHEN 'support@domain.com' THEN getSupportAddress('%s') ELSE goto END FROM alias_table WHERE address = '%s' AND active = 1;
// This mysql function does the hard work for selecting the least recently used destination and updating the database's timestamp
CREATE FUNCTION getSupportAddress (INOUT VARCHAR address) RETURNS varchar
BEGIN
-- select the address that was used least recently
SET @tmp = SELECT goto FROM alias WHERE address = @address ORDER BY last_used LIMIT 1;
-- update that address' timestamp with the current time, to avoid selecting it next time
UPDATE alias SET last_used = NOW() WHERE address = @address;
-- return the alias destination
RETURN @tmp;
END
It has the downside that you have to add an extra column (timestamp) to the aliases table only to keep account of the support alias usage.
Let me know if this is of any help!
Best regards!
German
|
First corrections to the function:
CREATE FUNCTION getSupportAddress (address VARCHAR) RETURNS varchar
BEGIN
-- select the address that was used least recently
SET @tmp = SELECT goto FROM alias WHERE address = @address ORDER BY last_used LIMIT 1;
-- update that address' timestamp with the current time, to avoid selecting it next time
UPDATE alias SET last_used = NOW() WHERE address = @tmp;
-- return the alias destination
RETURN @tmp;
END

|
|
|
All times are GMT -5. The time now is 09:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|