Why smtpd_recipient_limit and other email related options in postfix does not work?

喜欢而已 提交于 2019-12-08 09:50:33

问题


I have a server that runs on apache, and I am sending emails from that server. I want to set the number of recipients that each outgoing email can send to. I am following this tutorial and this manual - it seems to be as easy as adding smtpd_recipient_limit=2 to master.cf like below, reloading postfix, and running a test with 3 recipients. Each recipients still get email, with no error messages in /var/log/syslog file below. What is missing?

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# limit number of emails that can be send. Each outgoing mail are seperated by 
# 1 second delay. Number of recepients of each message is limited to 10.
#smtp_destination_rate_delay = 1s
#smtp_extra_recipient_limit = 10
#smtpd_client_message_rate_limit=2
smtpd_recipient_limit=2
smtpd_recipient_overshoot_limit=0

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = xxx
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
# (sorry have to smear out the domain name)
mydestination = xxx, localhost.xxx, , localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

#Added 

home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual

Log file below

Apr 10 22:35:54 xxx postfix/pickup[7448]: 16151400BC: uid=33 from=<www-data>
Apr 10 22:35:54 xxx postfix/cleanup[7455]: 16151400BC: message-id=<597dd15203e984495188a846c186772e@xxx>
Apr 10 22:35:54 xxx postfix/qmgr[7447]: 16151400BC: from=<www-data@xxx>, size=674, nrcpt=3 (queue active)
Apr 10 22:35:55 xxx postfix/smtp[7457]: 16151400BC: to=<yyy@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.196.27]:25, delay=1.5, delays=0.01/0/0.15/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1397183738 v62si6606269yhp.5 - gsmtp)
Apr 10 22:35:55 xxx postfix/smtp[7457]: 16151400BC: to=<zzz@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.196.27]:25, delay=1.5, delays=0.01/0/0.15/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1397183738 v62si6606269yhp.5 - gsmtp)
Apr 10 22:35:55 xxx postfix/smtp[7457]: 16151400BC: to=<ttt@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.196.27]:25, delay=1.5, delays=0.01/0/0.15/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1397183738 v62si6606269yhp.5 - gsmtp)
Apr 10 22:35:55 xxx postfix/qmgr[7447]: 16151400BC: removed

回答1:


  • It is because smtpd_recipient_limit only apply to the mails received by smtpd daemon through an SMTP transaction. The mails submitted using sendmail command is queued in maildrop queue by postdrop command, which is picked up by pickup and fed to cleanup directly.

  • You can't restrict recipient count for the mails submitted through sendmail command.

The only solution to this problem is force your applications to send mail only through smtp transaction.




回答2:


You need to use smtp_destination_recipient_limit instead.



来源:https://stackoverflow.com/questions/23003276/why-smtpd-recipient-limit-and-other-email-related-options-in-postfix-does-not-wo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!