· 10 years ago · Nov 05, 2015, 10:39 AM
1Hi,
2
3this explain my problem :
4 I want to filter (before queue) mails coming from known addresses and sent to choosen users.
5 I've written a filter script and it's almost working.
6 My only issue is, when the mail should be rejected, instead of sending a 5NN code, postfix sends 4NN code, so the SMTP client keep trying to send the unwanted mail.
7
8Here are the relevant part of my conf :
9
10master.cf
11 policy unix - n n - - spawn
12 user=nobody argv=/usr/bin/php -f /etc/postfix/my_filter.php
13
14main.cf
15 smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, check_policy_service unix:private/policy
16
17my_filter.php script send to stdout
18 action=DUNNO\n\n
19 if the mail should be accepted, this works perfectly
20 action=REJECT custom message\n\n
21 if the mail should be rejected, this is not working like I want
22 action=554 custom message\n\n
23 this results the same than "REJECT"
24
25Here are the relevant log from postfix, I test sending from a gmail account :
26 Nov 5 17:09:25 mydomain postfix/smtpd[21120]: connect from mail-pa0-f44.google.com[209.85.220.44]
27 Nov 5 17:09:26 mydomain postfix/smtpd[21120]: NOQUEUE: reject: RCPT from mail-pa0-f44.google.com[209.85.220.44]: 454 4.7.1 <mail@mydomain.tld>: Recipient address rejected: custom message; from=<mytestaccount@gmail.com> to=<mail@mydomain.tld> proto=ESMTP helo=<mail-pa0-f44.google.com>
28 Nov 5 17:09:26 mydomain postfix/smtpd[21120]: disconnect from mail-pa0-f44.google.com[209.85.220.44] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 quit=1 commands=5/7
29
30If I try to raise log_level :
31 debug_peer_level = 2
32 debug_peer_list = gmail.com
33The logs remain the same, no more help !
34
35As you can read in the logs, postfix answer with code "454 4.7.1", where I expect something like 5nn...
36So Gmail never stops to send the email, this can last several days...
37
38I also tried to chek the default error codes :
39
40postconf |grep reject_code
41 access_map_reject_code = 554
42 invalid_hostname_reject_code = 501
43 maps_rbl_reject_code = 554
44 multi_recipient_bounce_reject_code = 550
45 non_fqdn_reject_code = 504
46 plaintext_reject_code = 450
47 reject_code = 554
48 relay_domains_reject_code = 554
49 unknown_address_reject_code = 450
50 unknown_client_reject_code = 450
51 unknown_hostname_reject_code = 450
52 unknown_local_recipient_reject_code = 550
53 unknown_relay_recipient_reject_code = 550
54 unknown_virtual_alias_reject_code = 550
55 unknown_virtual_mailbox_reject_code = 550
56 unverified_recipient_reject_code = 450
57 unverified_sender_reject_code = 450
58
59According to documentation :
60 "The policy server replies with any action that is allowed in a Postfix SMTPD access(5) table"
61I don't know what I'm doing wrong, please help...
62
63Some more informations :
64 Gentoo : Base System release 2.2
65 Kernel : 3.14.32-xxxx-std-ipv6-64
66 Postfix : 3.0.2