Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

relay denied in postfix

1,639 views
Skip to first unread message

Tim Dunphy

unread,
Mar 15, 2014, 4:01:10 PM3/15/14
to
Hello,


I've just built a postfix server in amazon EC2 with an elastic IP. And I found that while I can connect to and send emails to my mail server when I telnet to localhost when I telnet to the external FQDN I get relay denied.

I'll first demonstrate success, then failure.

root@mail:~# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix (Ubuntu)
250 2.1.0 Ok
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test to internal localhost
.
250 2.0.0 Ok: queued as B97CA24B8B
quit

And the logs confirm success:

Mar 15 19:27:35 mail postfix/smtpd[5294]: B97CA24B8B: client=localhost[127.0.0.1]
Mar 15 19:28:18 mail postfix/cleanup[5306]: B97CA24B8B: message-id=<201403151927...@mail.example.com>
Mar 15 19:28:18 mail postfix/qmgr[5221]: B97CA24B8B: from=<bluet...@external.com>, size=356, nrcpt=1 (queue active)
Mar 15 19:28:18 mail postfix/cleanup[5306]: AD51725096: message-id=<201403151927...@mail.example.com>
Mar 15 19:28:18 mail amavis[3401]: (03401-09) Passed BAD-HEADER-1 {RelayedOutbound,Quarantined}, LOCAL [127.0.0.1]:58766 [127.0.0.1] <bluet...@external.com> -> <bluet...@example.com>, quarantine: W/badh-WyjD4kEQ4Mls, Queue-ID: B97CA24B8B, Message-ID: <201403151927...@mail.example.com>, mail_id: WyjD4kEQ4Mls, Hits: -, size: 356, queued_as: AD51725096, 140 ms
Mar 15 19:28:18 mail postfix/smtp[5317]: B97CA24B8B: to=<bluet...@example.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=51, delays=51/0.03/0/0.16, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as AD51725096)
Mar 15 19:28:18 mail postfix/qmgr[5221]: B97CA24B8B: removed

However, if I telnet to the externally available FQDN (from the mail server) I get a relay denied error:

root@mail:~# telnet mail.example.com 25
Trying xx.xx.xx.xx...
Connected to mail.example.com.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix (Ubuntu)
250 2.1.0 Ok
454 4.7.1 <bluet...@example.com>: Relay access denied

In the logs when I try to telnet to the FQDN, I see this:

Mar 15 19:38:00 mail postfix/smtpd[5392]: NOQUEUE: reject: RCPT from unknown[54.85.41.178]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<bluet...@external.com> to=<bluet...@example.com> proto=SMTP helo=<mail.example.com>

I've done some googling on this, and often people do site this setting as a potential cause of this situation. Here's mine, although nothing seems to stand out: 

smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated,  reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, check_policy_service inet:127.0.0.1:10023, permit

Here is the output of postconf -n

root@mail:~# postconf -n

alias_database = hash:/etc/postfix/aliases

alias_maps = hash:/etc/postfix/aliases

append_dot_mydomain = no

biff = no

broken_sasl_auth_clients = no

config_directory = /etc/postfix

content_filter = amavis:[127.0.0.1]:10024

delay_warning_time = 4h

disable_vrfy_command = yes

inet_interfaces = all

local_recipient_maps =

mailbox_size_limit = 0

masquerade_domains = mail.example.com example.com !sub.dyndomain.com

masquerade_exceptions = root

maximal_backoff_time = 8000s

maximal_queue_lifetime = 7d

minimal_backoff_time = 1000s

mydestination =

myhostname = mail.example.com

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

mynetworks_style = host

myorigin = example.com

readme_directory = no

recipient_delimiter = +

relayhost =

smtp_helo_timeout = 60s

smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

smtp_tls_note_starttls_offer = yes

smtp_tls_security_level = may

smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)

smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, reject_rbl_client blackholes.easynet.nl

smtpd_data_restrictions = reject_unauth_pipelining

smtpd_delay_reject = yes

smtpd_hard_error_limit = 12

smtpd_helo_required = yes

smtpd_helo_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_hostname, reject_invalid_hostname, permit

smtpd_recipient_limit = 16

smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, check_policy_service inet:127.0.0.1:10023, permit

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

smtpd_sasl_auth_enable = yes

Another potential trouble area may be that I can't seem to telnet to port 25 remotely from my work station: 


[me@home:~] #telnet mail.example.com 25

Trying xx.xx.xx.xx..

telnet: connect to address xx.xx.xx.xx: Operation timed out

telnet: Unable to connect to remote host


As mentioned this is an amazon EC2 instance, but I have opened up port 25 on the security groups and made sure that ufw (the ubuntu firewall) was not running on the instance.

I'd definitely appreciate your esteemed advice on this!

Thanks,

Tim



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

Tim Dunphy

unread,
Mar 15, 2014, 10:40:17 PM3/15/14
to
Hey all,

 I fixed the problem with being able to access the FQDN of the mail host via telnet from the command line by editing mynetworks to contain the name of the mail host:


But it appears that mail IS making its way to the mail server, but being rejected once it arrives. 

Here's an example of a mail rejected from yahoo

Mar 16 02:27:58 mail postfix/smtpd[22335]: connect from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]

Mar 16 02:27:59 mail postfix/smtpd[22335]: Anonymous TLS connection established from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)

Mar 16 02:27:59 mail postfix/smtpd[22335]: NOQUEUE: reject: RCPT from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<reg.gi3tqmjyge4dama-bluethundr=examp...@returns.bulk.external.com> to=<bluet...@example.com> proto=ESMTP helo=<n11-vm3.bullet.mail.bf1.external.com>

Mar 16 02:27:59 mail postfix/smtpd[22335]: disconnect from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]

Mar 16 02:30:55 mail postfix/smtpd[22335]: connect from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]

Mar 16 02:30:55 mail postfix/smtpd[22335]: Anonymous TLS connection established from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]: TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)

Mar 16 02:30:55 mail postfix/smtpd[22335]: NOQUEUE: reject: RCPT from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<reg.gi3tqmjyge4dama-bluethundr=examp...@returns.bulk.external.com> to=<bluet...@example.com> proto=ESMTP helo=<n11-vm3.bullet.mail.bf1.external.com>

Mar 16 02:30:55 mail postfix/smtpd[22335]: disconnect from n11-vm3.bullet.mail.bf1.external.com[66.196.81.194]

Mar 16 02:31:41 mail postfix/smtpd[22335]: connect from nm48.bullet.mail.ne1.external.com[98.138.120.55]Mar 16 02:31:41 mail postfix/smtpd[22335]: NOQUEUE: reject: RCPT from nm48.bullet.mail.ne1.external.com[98.138.120.55]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<blueth...@external.com> to=<bluet...@example.com> proto=SMTP helo=<nm48.bullet.mail.ne1.external.com>Mar 16 02:31:41 mail postfix/smtpd[22335]: disconnect from nm48.bullet.mail.ne1.external.com[98.138.120.55]

Mar 16 02:33:24 mail postfix/smtpd[22335]: connect from nm48.bullet.mail.ne1.external.com[98.138.120.55]

Mar 16 02:33:24 mail postfix/smtpd[22335]: NOQUEUE: reject: RCPT from nm48.bullet.mail.ne1.external.com[98.138.120.55]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<blueth...@external.com> to=<bluet...@example.com> proto=SMTP helo=<nm48.bullet.mail.ne1.external.com>

Mar 16 02:33:24 mail postfix/smtpd[22335]: disconnect from nm48.bullet.mail.ne1.external.com[98.138.120.55]



And here's an example from gmail


Mar 16 02:23:20 mail postfix/smtpd[21652]: NOQUEUE: reject: RCPT from mail-la0-f48.google.com[209.85.215.48]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<bluet...@external.com> to=<bluet...@example.com> proto=ESMTP helo=<mail-la0-f48.google.com>

Mar 16 02:35:01 mail postfix/smtpd[22335]: NOQUEUE: reject: RCPT from mail-lb0-f177.google.com[209.85.217.177]: 454 4.7.1 <bluet...@example.com>: Relay access denied; from=<bluet...@external.com> to=<bluet...@example.com> proto=ESMTP helo=<mail-lb0-f177.google.com>


OK, so it seems as if I'm in the home stretch! What do I need to alter in my postfix configuration to get this mail server rocking?


Thanks!

Tim

Noel Jones

unread,
Mar 15, 2014, 11:29:45 PM3/15/14
to
On 3/15/2014 9:40 PM, Tim Dunphy wrote:
> Hey all,
>
> But it appears that mail IS making its way to the mail server, but
> being rejected once it arrives.
>
> Here's an example of a mail rejected from yahoo
>
>
> Mar 16 02:27:59 mail postfix/smtpd[22335]: NOQUEUE: reject: RCPT
> from n11-vm3.bullet.mail.bf1.external.com
> <http://n11-vm3.bullet.mail.bf1.external.com>[66.196.81.194]: 454
> 4.7.1 <bluet...@example.com <mailto:bluet...@example.com>>:
> Relay access denied;
> from=<reg.gi3tqmjyge4dama-bluethundr=examp...@returns.bulk.external.com
> <mailto:examp...@returns.bulk.external.com>>
> to=<bluet...@example.com <mailto:bluet...@example.com>>
> proto=ESMTP helo=<n11-vm3.bullet.mail.bf1.external.com
> <http://n11-vm3.bullet.mail.bf1.external.com>>


Postfix doesn't know it should accept mail for example.com.

example.com must be listed in *one* of mydestination, relay_domains,
virtual_mailbox_domains, virtual_alias_domains, depending on where
the mail is to be delivered.

http://www.postfix.org/ADDRESS_CLASS_README.html
http://www.postfix.org/BASIC_CONFIGURATION_README.html
http://www.postfix.org/SOHO_README.html
http://www.postfix.org/STANDARD_CONFIGURATION_README.html



-- Noel Jones

Tim Dunphy

unread,
Mar 16, 2014, 12:12:10 PM3/16/14
to
Guys,

 For some reason gmail decided to shunt this conversation into my spam folder. So, sorry if I've missed any of your replies. 

At any rate I had a perusal of the digest form of the list and found this reply from Noel:

Postfix doesn't know it should accept mail for example.com.
example.com must be listed in *one* of mydestination, relay_domains,
virtual_mailbox_domains, virtual_alias_domains, depending on where
the mail is to be delivered.


So my thanks to Noel. I set 'mydestination' to example.com and lo and behold my new mail server started recieving emails. In such a way that I could pull them up in the roundcube webmail interface. Neat!

However one thing that's still puzzling me is that my routing needs SHOULD be covered by my virtual_mailbox_domains setting, as best I would know.

This is how I have that set in main.cf :

virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf


And this is what I have in my database:

mysql> select * from domains;

+------+-----------------------+-----------+---------+

| pkid | domain                | transport | enabled |

+------+-----------------------+-----------+---------+

|    1 | localhost             | virtual:  |       1 |

|    2 | localhost.localdomain | virtual:  |       1 |

|    3 | example.com          | virtual:  |       1 |

|    4 | mail.example.com     | virtual:  |       1 |

|    5 | example2.com             | virtual:  |       1 |

|    6 | mail.example2.com        | virtual:  |       1 |

+------+-----------------------+-----------+---------+

6 rows in set (0.00 sec)


It seems that postfix is able to read from the database, as would be evidenced of my being able to receive emails to accounts that are stored in the db. So why it's unable to read from the domains list is a bit puzzling.

Here's my current postconf -n output if anyone would like to help with advice on why virtual domains aren't working as desired.


[root@mail:~] #postconf -n

alias_database = hash:/etc/postfix/aliases

alias_maps = hash:/etc/postfix/aliases

append_dot_mydomain = no

biff = no

broken_sasl_auth_clients = no

config_directory = /etc/postfix

content_filter = amavis:[127.0.0.1]:10024

delay_warning_time = 4h

disable_vrfy_command = yes

inet_interfaces = all

local_recipient_maps =

mailbox_size_limit = 0

masquerade_exceptions = root

maximal_backoff_time = 8000s

maximal_queue_lifetime = 7d

minimal_backoff_time = 1000s

mydestination = mail.jokefire.com jokefire.com

myhostname = mail.jokefire.com

mynetworks = 127.0.0.0/8 mail.jokefire.com

mynetworks_style = host

myorigin = jokefire.com

readme_directory = no

recipient_delimiter = +

relayhost =

smtp_helo_timeout = 60s

smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

smtp_tls_note_starttls_offer = yes

smtp_tls_security_level = may

smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)

smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, reject_rbl_client blackholes.easynet.nl

smtpd_data_restrictions = reject_unauth_pipelining

smtpd_delay_reject = yes

smtpd_hard_error_limit = 12

smtpd_helo_required = yes

smtpd_helo_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_hostname, reject_invalid_hostname, permit

smtpd_recipient_limit = 16

smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, check_policy_service inet:127.0.0.1:10023, permit

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination

smtpd_sasl_auth_enable = yes

smtpd_sasl_local_domain =

smtpd_sasl_security_options = noanonymous

smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit

smtpd_soft_error_limit = 3

smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem

smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key

smtpd_tls_loglevel = 1

smtpd_tls_received_header = yes

smtpd_tls_security_level = may

smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache

smtpd_tls_session_cache_timeout = 3600s

smtpd_use_tls = yes

tls_random_source = dev:/dev/urandom

transport_maps = mysql:/etc/postfix/mysql_transport.cf

unknown_local_recipient_reject_code = 450

virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf

virtual_gid_maps = static:5000

virtual_mailbox_base = /var/spool/mail/virtual

virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf

virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf

virtual_uid_maps = static:5000


Thanks!

Tim



 


Noel Jones

unread,
Mar 16, 2014, 1:12:59 PM3/16/14
to
On 3/16/2014 11:12 AM, Tim Dunphy wrote:
> Guys,
>
> For some reason gmail decided to shunt this conversation into my
> spam folder. So, sorry if I've missed any of your replies.
>
> At any rate I had a perusal of the digest form of the list and found
> this reply from Noel:
>
> Postfix doesn't know it should accept mail for example.com
> <http://example.com/>.
> example.com <http://example.com/> must be listed in *one* of
> mydestination, relay_domains,
> virtual_mailbox_domains, virtual_alias_domains, depending on where
> the mail is to be delivered.
>
>
>
> So my thanks to Noel. I set 'mydestination' to example.com
> <http://example.com> and lo and behold my new mail server started
> recieving emails. In such a way that I could pull them up in the
> roundcube webmail interface. Neat!
>
> However one thing that's still puzzling me is that my routing needs
> SHOULD be covered by my virtual_mailbox_domains setting, as best I
> would know.

[please post in plain-text only]

Do not list your domain in more than one place, otherwise postfix
will log warnings and various things may not work as expected.

Apparently your virtual_mailbox_domains lookup isn't working. Test
your lookup with:
postmap -q example.com mysql:/etc/postfix/mysql_domains.cf

Listed domains should return a result -- any non-empty result is
considered valid.

Nothing should be printed when testing unlisted domains.



-- Noel Jones

bluet...@jokefire.com

unread,
Mar 16, 2014, 1:24:10 PM3/16/14
to
> Do not list your domain in more than one place, otherwise postfix
> will log warnings and various things may not work as expected.
>

Good advice. Thanks.


> Apparently your virtual_mailbox_domains lookup isn't working. Test
> your lookup with:
> postmap -q example.com mysql:/etc/postfix/mysql_domains.cf
>
> Listed domains should return a result -- any non-empty result is
> considered valid.
>
> Nothing should be printed when testing unlisted domains.

Hmm from this test it looks like I'm not pulling any info from mysql:

[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_domains.cf
[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_mailbox.cf
[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_alias.cf
[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_transport.cf

I actually tried testing all my mysql conf files this way and no info
was returned from any of them!

And I do have postfix-mysql installed.

[root@mail:/etc/postfix] #dpkg -l | grep postfix
ii postfix 2.10.2-1
amd64 High-performance mail transport agent
ii postfix-mysql 2.10.2-1
amd64 MySQL map support for Postfix

I'm wondering if there is some flaw in my config that is preventing
postfix from reading from the db? I'd really appreciate any advice you
might have n getting postfix to interface with mysql.

Thanks
Tim

Noel Jones

unread,
Mar 16, 2014, 8:19:29 PM3/16/14
to
Sorry, I don't use sql and am unable to provide help beyond knowing
what response postfix expects.

Maybe someone else can help with your sql queries. Start a new
thread asking about this specific problem.



-- Noel Jones

Sergei

unread,
Mar 16, 2014, 8:27:02 PM3/16/14
to
On Sunday 16 March 2014 13:24:10 bluet...@jokefire.com wrote:
> I'm wondering if there is some flaw in my config that is preventing
> postfix from reading from the db? I'd really appreciate any advice you
> might have n getting postfix to interface with mysql.

Try the connection specified in the files manually by logging as that exact user
and running the query. You might get some useful error messages from MySQL.

bluet...@jokefire.com

unread,
Mar 16, 2014, 8:39:39 PM3/16/14
to
> Sorry, I don't use sql and am unable to provide help beyond knowing
> what response postfix expects.
>
> Maybe someone else can help with your sql queries. Start a new
> thread asking about this specific problem.

No problem, Noel. Thanks for your response. I'll do that at some point
shortly I'm sure. I actually used flurdy's postfix guide for the whole
thing. I sort of doubt the SQL is to blame. Maybe more of an Ubuntu
specific install issue where postfix can't communicate with the
database. Maybe I'll hit up the ubuntu forums with this problem at some
point.

Thanks again,
Tim
>> I'm wondering if there is some flaw in my config that is preventing
>> postfix from reading from the db? I'd really appreciate any advice
>> you might have n getting postfix to interface with mysql.
>>

bluet...@jokefire.com

unread,
Mar 16, 2014, 9:19:24 PM3/16/14
to
Hi Sergei

> Try the connection specified in the files manually by logging as that
> exact user
> and running the query. You might get some useful error messages from
> MySQL.

I tried pulling the info specified in the mysql_domains.cf file that's
specified to retrieve domain info in my postfix setup. Here's what the
file looks like:

[root@mail:/etc/postfix] #cat mysql_domains.cf
user=mail
password=secret
dbname=maildb
table=domains
select_field=domain
where_field=domain
hosts=127.0.0.1
additional_conditions = and enabled = 10

And I'm able to pull the info from the command line using the query
specified in the file:

[root@mail:/etc/postfix] #mysql -umail -p -h 127.0.0.1 maildb -e "select
domain from domains where domain like 'example.com'"
Enter password:
+--------------+
| domain |
+--------------+
| example.com |
+--------------+


Yet, nothing is still returned by querying the file using postmap:

[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_domains.cf
[root@mail:/etc/postfix] #


Any further ideas would be welcome.

Thanks,
Tim

Sergei

unread,
Mar 16, 2014, 9:28:02 PM3/16/14
to
On Sunday 16 March 2014 21:19:24 bluet...@jokefire.com wrote:
> user=mail
> password=secret
> dbname=maildb
> table=domains
> select_field=domain
> where_field=domain
> hosts=127.0.0.1
> additional_conditions = and enabled = 10

I am not familiar with this syntax. I use the following:

user = mail
password = secret
hosts = 127.0.0.1
dbname = maildb
query = SELECT * FROM domains WHERE domain='%s'

You might want to try this instead.

Viktor Dukhovni

unread,
Mar 16, 2014, 9:32:52 PM3/16/14
to
Better:

query = SELECT domain FROM domains WHERE domain='%s' AND enabled = 10

there is no need to select all the columns. (No idea what the
significance of "enabled = 10" is, except that seemingly this is
what the OP wants or perhaps it is the reason why no results are
returned).

--
Viktor.

bluet...@jokefire.com

unread,
Mar 16, 2014, 9:52:39 PM3/16/14
to
Thanks guys! This did the trick! However it looks like I have a type-o
causing the problems. Instead of 'enabled = 10' should be 'enabled = 1'.
LOL

user = mail
password = secret
hosts = 127.0.0.1
dbname = maildb
query = SELECT * FROM domains WHERE domain='%s' AND enabled = 1

Using the above query works fine with postfix:

[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_domains.cf
3,example.com,virtual:,1

Once again, thank you ALL for your suggestions. Glad we got this one
solved.

Tim

bluet...@jokefire.com

unread,
Mar 16, 2014, 10:04:38 PM3/16/14
to
Actually I should probably point out that the original syntax does work
better:

[root@mail:/etc/postfix] #cat mysql_domains.cf
user=mail
password=secret
dbname=maildb
table=domains
select_field=domain
where_field=domain
hosts=127.0.0.1
additional_conditions = and enabled = 1


[root@mail:/etc/postfix] #postmap -q example.com
mysql:/etc/postfix/mysql_domains.cf
example.com

As opposed to the following output:

[root@mail:/etc/postfix] #postmap -q example.com
> mysql:/etc/postfix/mysql_domains.cf
> 3,example.com,virtual:,1

Using this syntax:

> user = mail
> password = secret
> hosts = 127.0.0.1
> dbname = maildb
> query = SELECT * FROM domains WHERE domain='%s' AND enabled = 1

Tim

Viktor Dukhovni

unread,
Mar 16, 2014, 10:27:42 PM3/16/14
to
On Sun, Mar 16, 2014 at 10:04:38PM -0400, bluet...@jokefire.com wrote:

> > Better:
> >
> > query = SELECT domain FROM domains WHERE domain='%s' AND enabled = 10
> >
> > there is no need to select all the columns. (No idea what the
> > significance of "enabled = 10" is, except that seemingly this is
> > what the OP wants or perhaps it is the reason why no results are
> > returned).
>
> Actually I should probably point out that the original syntax does work
> better:

Inattention to detail!

> [root@mail:/etc/postfix] #postmap -q example.com
> >mysql:/etc/postfix/mysql_domains.cf
> >3,example.com,virtual:,1

Because you're selecting all the columns.

> Using this syntax:
>
> >user = mail
> >password = secret
> >hosts = 127.0.0.1
> >dbname = maildb
> >query = SELECT * FROM domains WHERE domain='%s' AND enabled = 1

See above. The syntax you're using is obsolete. Use "query = ...".

--
Viktor.

bluet...@jokefire.com

unread,
Mar 16, 2014, 10:46:01 PM3/16/14
to
On 2014-03-16 22:27, Viktor Dukhovni wrote:
> On Sun, Mar 16, 2014 at 10:04:38PM -0400, bluet...@jokefire.com
> wrote:
>
>> > Better:
>> >
>> > query = SELECT domain FROM domains WHERE domain='%s' AND enabled = 10
>> >
>> > there is no need to select all the columns. (No idea what the
>> > significance of "enabled = 10" is, except that seemingly this is
>> > what the OP wants or perhaps it is the reason why no results are
>> > returned).
>>
>> Actually I should probably point out that the original syntax does
>> work
>> better:
>
> Inattention to detail!

Unfortunately. :-(

>
>> [root@mail:/etc/postfix] #postmap -q example.com
>> >mysql:/etc/postfix/mysql_domains.cf
>> >3,example.com,virtual:,1
>
> Because you're selecting all the columns.
>
>> Using this syntax:
>>
>> >user = mail
>> >password = secret
>> >hosts = 127.0.0.1
>> >dbname = maildb
>> >query = SELECT * FROM domains WHERE domain='%s' AND enabled = 1
>
> See above. The syntax you're using is obsolete. Use "query = ...".

OK, you talked me into it! :-) I tried your suggested syntax in action
with my setup. It works. I'm keeping it. Appreciate the advice!

Tim

0 new messages