Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have my own server, with postfix as mailserver. My clients have to be able to use this mailserver as well. They use software written in c# to send emails, but since my last upgrade the smtp authentication doesn't work properly so I have to use the myNetwork setting in For dynamically allocated IP adresses, or employees of my clients working from home, this gives the problem that I have to manually adjust the everytime a mail is rejected by the mail server.

I allready use MySQL for users and domains so the configuration should be OK:

virtual_mailbox_domains = mysql:/etc/postfix/

virtual_mailbox_maps = mysql:/etc/postfix/

virtual_alias_maps = mysql:/etc/postfix/,mysql:/etc/postfix

But if I use:

mynetworks = mysql:/etc/postfix/

which contains:

user = MailUserName
password = MailUserPassWord
hosts =
dbname = MailDatabase
query = Select IPNummer from MyNetworks where IPNummer = '%s'
expansion_limit = 100

I get the following error on sending an email: Temporary lookup failure

Of course I've googled extensively, but the usual suspects like the encoding have been tried and give no result.

If anybody can give a pointer to the solution I would be very gratefull.

share|improve this question
Thanks Tom O'Connor for editing my question, it looks certainly better! – RobRdam Dec 6 '12 at 5:38

but since my last upgrade the smtp authentication doesn't work properly

You need to fix this.

mynetworks is not meant to grant outsiders free reign on your mail server system; you should restrict it to localhost 99% of the time.

share|improve this answer
Well, restricting to local network can be a fairly legitimate setting as well. Not that that distinction has much to do with the original question, but still. – andol Dec 7 '12 at 15:12
@adaptr This answer needs to have 1000 upvotes! – mailq Dec 9 '12 at 20:54
I...agree? A whole year to get to 10K was ridiculous! – adaptr Dec 10 '12 at 9:14

I think it's a bad idea. However if you were going to try it, you'd need some way to store IPs and netmasks in your table and query against the ranges. That would be kind of complicated with regex and whatnot, so I'd take the shortcut and create a table that looks like this by converting the first and last IP in each range to an integer. In this example

|first_ip |last_ip  |action|
|180097280|180097535|OK |

Then I'd create a query to determine if the IP were between first and last and return the action or wherever Postfix wants. I'm not certain this actually works, but it seems feasible.

That said it seems far simpler, more reliable, and does not require constant updates to your database to fix whatever went wrong with smtp auth.

share|improve this answer
I stored the IP as a string because that's the format used in the mynetworks setting in – RobRdam Dec 6 '12 at 5:13
I tried the integer approach, but I still get the 'Temporary lookup error' by the way, I send emails through an application that allready uses another MySQL database on the server, so updating from my email routine is no problem. I agree solving the smtp auth would be better, but I've been working on that since august! – RobRdam Dec 6 '12 at 5:35
You'd need to write the sql to convert dotted quad to integer and then check the range. Test that manually before letting Postifx at it. I still believe fixing smtp auth is an order of magnitude easier than what you're trying to do. – kashani Dec 6 '12 at 17:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.