Re: [Mailman-Users] Automate Moderator Functions
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Hi,
i`m trying to reject messages bigger then MAX_MESSAGE_SIZE.
I configured my Hold.py was described bellow:
replaced
hold_for_approval(mlist, msg, msgdata,
_
MessageTooBig(bodylen,_mlist.max_message_size))
with
rej = MessageTooBig(bodylen, mlist.max_message_size)
_ raise Errors.RejectMessage, rej.reason_notice_
The message was rejected, but the sender dont receive any notify about that. The mailman vette log too. How can i solve this?
Thanks,
André
Dennis Putnam wrote:
There are two ways to proceed.
You can modify Mailman/Handlers/Hold.py itself, but before overwriting it, make a "diff -u" between the base Hold.py and your modified version to use as a patch to apply after any upgrade.
A better way is to leave Hold.py unchanged and make your own edited version as say Mailman/Handlers/MyHold.py. Then you can replace the base Hold.py Module with your MyHold.py by putting
GLOBAL_PIPELINE[GLOBAL_PIPELINE.index('Hold')] = 'MyHold'
in mm_cfg.py. Note that if you are going to do this, and you want also to move MimeDel before Hold, you must either put the above line after the lines
GLOBAL_PIPELINE.remove('MimeDel') GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('Hold'), 'MimeDel')
in mm_cfg.py or put it before, but then also change
GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('Hold'), 'MimeDel')
to
GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('MyHold'), 'MimeDel')
I recommend the former as in
# # Put MimeDel ahead of Hold so "too big" is based on content filtered # message. # GLOBAL_PIPELINE.remove('MimeDel') GLOBAL_PIPELINE.insert(GLOBAL_PIPELINE.index('Hold'), 'MimeDel') # # Replace Hold with local version # GLOBAL_PIPELINE[GLOBAL_PIPELINE.index('Hold')] = 'MyHold'
Since mm_cfg.py survives upgrades, this should survive.
Also does this same procedure apply to other automatic rejections such as implicit destination?
Yes, similar changes would apply to other holds in Hold.py.
-- Mark Sapiro <mark at msapiro.net [1]> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
--
Links:
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 09/02/2016 01:45 PM, Andre de Azevedo Cunha wrote:
Logging for rejected messages was added in 2.1.16. See <https://bugs.launchpad.net/mailman/+bug/1068837>. Prior to that, there won't be a vette log entry.
I don't know why there isn't a notice to the user. Is there anything in Mailman's error log?
As a test, add some nonmember address to the list's reject_these_nonmembers and send a post from that address. Does that receive a rejection notice?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Mark,
the important to me is reject emails to the lists bigger then the value
set in MAX_MESSAGE_SIZE in the lists config. The default behavior is moderate this message, what don
t solve me problem. Exist one way to do
this?
Em 03/09/2016 13:00, Mark Sapiro escreveu:
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 09/05/2016 07:10 AM, Andre de Azevedo Cunha wrote:
I understand what you are trying to do and what you have done should work. As I said in my prior reply
In order to help further, I need more information. Did you look in Mailman's error log? Did you do the test suggested above?
Send me off list a copy of your modified Mailman/Handlers/Hold.py module and I'll look at it to see if there is a problem there.
Also, if you want rejections to be logged in vette, you can apply the attached patch to Mailman/Queue/IncommingRunner.py.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Mark,
i solved like this:
REPLACED THIS:
#default action (moderate) #hold_for_approval(mlist, msg, msgdata, # MessageTooBig(bodylen, mlist.max_message_size))
FOR THIS:
#auto rejecting emails bigger then max_message_size f_log=open('/var/log/mailman/reject','a') f_log.write('Message from %s to %s rejected. Size exceed: %s KB\n'% (sender, listname, bodylen/1024)) f_log.close() rej2="Our message was rejected because is bigger then list max value ( %s KB ), please reduce the message to bellow of %s KB and try again"% (bodylen/1024, mlist.max_message_size) raise Errors.RejectMessage, rej2
Thanks for your support and availability.
Regards,
Em 05/09/2016 12:57, Mark Sapiro escreveu:
In order to help further, I need more information. Did you look in Mailman's error log? Did you do the test suggested above?
Send me off list a copy of your modified Mailman/Handlers/Hold.py module and I'll look at it to see if there is a problem there.
Also, if you want rejections to be logged in vette, you can apply the attached patch to Mailman/Queue/IncommingRunner.py.
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Hi!
I'm testing the migration of my mailman2 lists to mailman3. Had made the adjustment below to discard messages larger than the list size limit. But I'm having difficulties to implement the same solution in mailman3. How could I do this?
Em 05/09/2016 13:16, Andre de Azevedo Cunha escreveu:
In order to help further, I need more information. Did you look in Mailman's error log? Did you do the test suggested above?
Send me off list a copy of your modified Mailman/Handlers/Hold.py module and I'll look at it to see if there is a problem there.
Also, if you want rejections to be logged in vette, you can apply the attached patch to Mailman/Queue/IncommingRunner.py.
Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/acunha%40iff.edu.br
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 4/14/22 10:29, Andre de Azevedo Cunha wrote:
something like ``` diff --git a/src/mailman/chains/builtin.py b/src/mailman/chains/builtin.py index ecb56d67f..ba3a3b4bc 100644 --- a/src/mailman/chains/builtin.py +++ b/src/mailman/chains/builtin.py @@ -59,7 +59,7 @@ class BuiltInChain: ('administrivia', LinkAction.defer, None), ('implicit-dest', LinkAction.defer, None), ('max-recipients', LinkAction.defer, None), - ('max-size', LinkAction.defer, None), + ('max-size', LinkAction.jump, 'reject'), ('news-moderation', LinkAction.defer, None), ('no-subject', LinkAction.defer, None), ('digests', LinkAction.defer, None), diff --git a/src/mailman/rules/max_size.py b/src/mailman/rules/max_size.py index 50de9ff5d..53cb3ae50 100644 --- a/src/mailman/rules/max_size.py +++ b/src/mailman/rules/max_size.py @@ -65,7 +65,9 @@ class MaximumSize: with _.defer_translation(): # This will be translated at the point of use. msgdata.setdefault('moderation_reasons', []).append( - (_('The message is larger than the {} KB maximum size'), - mlist.max_message_size)) + (_('Your message was rejected because is bigger than the ' + 'list max value ({} Kb), please reduce the message to ' + 'below {} KB and try again.').format( + test_size, mlist.max_message_size))) return True return False ``` -- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 4/14/22 12:11, Andre de Azevedo Cunha wrote:
The change works, the message was discarted, but the sender dont received the notify. I`m trying to understand why.
The message should be returned to the sender with notice as to why. Is it possible it was discarded for some other reason?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Mark,
i solved with this code:
# diff chains/builtin.py.ori chains/builtin.py 62c62 < ('max-size', LinkAction.defer, None),
('max-size', LinkAction.jump, 'reject'),
# diff rules/max_size.py.ori rules/max_size.py 47c47 < (_('The message is larger than the {} KB maximum size'),
(_('Your message was rejected because is bigger than the list max value {} KB, please reduce the message and try again'),
Em 18/04/2022 14:37, Andre de Azevedo Cunha escreveu:
Mailman-Users mailing list -- mailman-users@python.org To unsubscribe send an email to mailman-users-leave@python.org https://mail.python.org/mailman3/lists/mailman-users.python.org/ Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: https://www.mail-archive.com/mailman-users@python.org/ https://mail.python.org/archives/list/mailman-users@python.org/
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
with correct return text:
# diff rules/max_size.py.ori rules/max_size.py 47,48c47,48 < (_('The message is larger than the {} KB maximum size'), < mlist.max_message_size))
(_('Your message was rejected because is bigger ( {} KB ) than the list max value, please reduce the message to bellow of {} KB and try again'), round(msg.original_size/1024.0,2),mlist.max_message_size))
Em 18/04/2022 14:59, Andre de Azevedo Cunha escreveu:
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 09/02/2016 01:45 PM, Andre de Azevedo Cunha wrote:
Logging for rejected messages was added in 2.1.16. See <https://bugs.launchpad.net/mailman/+bug/1068837>. Prior to that, there won't be a vette log entry.
I don't know why there isn't a notice to the user. Is there anything in Mailman's error log?
As a test, add some nonmember address to the list's reject_these_nonmembers and send a post from that address. Does that receive a rejection notice?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Mark,
the important to me is reject emails to the lists bigger then the value
set in MAX_MESSAGE_SIZE in the lists config. The default behavior is moderate this message, what don
t solve me problem. Exist one way to do
this?
Em 03/09/2016 13:00, Mark Sapiro escreveu:
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 09/05/2016 07:10 AM, Andre de Azevedo Cunha wrote:
I understand what you are trying to do and what you have done should work. As I said in my prior reply
In order to help further, I need more information. Did you look in Mailman's error log? Did you do the test suggested above?
Send me off list a copy of your modified Mailman/Handlers/Hold.py module and I'll look at it to see if there is a problem there.
Also, if you want rejections to be logged in vette, you can apply the attached patch to Mailman/Queue/IncommingRunner.py.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Mark,
i solved like this:
REPLACED THIS:
#default action (moderate) #hold_for_approval(mlist, msg, msgdata, # MessageTooBig(bodylen, mlist.max_message_size))
FOR THIS:
#auto rejecting emails bigger then max_message_size f_log=open('/var/log/mailman/reject','a') f_log.write('Message from %s to %s rejected. Size exceed: %s KB\n'% (sender, listname, bodylen/1024)) f_log.close() rej2="Our message was rejected because is bigger then list max value ( %s KB ), please reduce the message to bellow of %s KB and try again"% (bodylen/1024, mlist.max_message_size) raise Errors.RejectMessage, rej2
Thanks for your support and availability.
Regards,
Em 05/09/2016 12:57, Mark Sapiro escreveu:
In order to help further, I need more information. Did you look in Mailman's error log? Did you do the test suggested above?
Send me off list a copy of your modified Mailman/Handlers/Hold.py module and I'll look at it to see if there is a problem there.
Also, if you want rejections to be logged in vette, you can apply the attached patch to Mailman/Queue/IncommingRunner.py.
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Hi!
I'm testing the migration of my mailman2 lists to mailman3. Had made the adjustment below to discard messages larger than the list size limit. But I'm having difficulties to implement the same solution in mailman3. How could I do this?
Em 05/09/2016 13:16, Andre de Azevedo Cunha escreveu:
In order to help further, I need more information. Did you look in Mailman's error log? Did you do the test suggested above?
Send me off list a copy of your modified Mailman/Handlers/Hold.py module and I'll look at it to see if there is a problem there.
Also, if you want rejections to be logged in vette, you can apply the attached patch to Mailman/Queue/IncommingRunner.py.
Mailman-Users mailing list Mailman-Users@python.org https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/acunha%40iff.edu.br
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 4/14/22 10:29, Andre de Azevedo Cunha wrote:
something like ``` diff --git a/src/mailman/chains/builtin.py b/src/mailman/chains/builtin.py index ecb56d67f..ba3a3b4bc 100644 --- a/src/mailman/chains/builtin.py +++ b/src/mailman/chains/builtin.py @@ -59,7 +59,7 @@ class BuiltInChain: ('administrivia', LinkAction.defer, None), ('implicit-dest', LinkAction.defer, None), ('max-recipients', LinkAction.defer, None), - ('max-size', LinkAction.defer, None), + ('max-size', LinkAction.jump, 'reject'), ('news-moderation', LinkAction.defer, None), ('no-subject', LinkAction.defer, None), ('digests', LinkAction.defer, None), diff --git a/src/mailman/rules/max_size.py b/src/mailman/rules/max_size.py index 50de9ff5d..53cb3ae50 100644 --- a/src/mailman/rules/max_size.py +++ b/src/mailman/rules/max_size.py @@ -65,7 +65,9 @@ class MaximumSize: with _.defer_translation(): # This will be translated at the point of use. msgdata.setdefault('moderation_reasons', []).append( - (_('The message is larger than the {} KB maximum size'), - mlist.max_message_size)) + (_('Your message was rejected because is bigger than the ' + 'list max value ({} Kb), please reduce the message to ' + 'below {} KB and try again.').format( + test_size, mlist.max_message_size))) return True return False ``` -- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/56f108518d7ee2544412cc80978e3182.jpg?s=120&d=mm&r=g)
On 4/14/22 12:11, Andre de Azevedo Cunha wrote:
The change works, the message was discarted, but the sender dont received the notify. I`m trying to understand why.
The message should be returned to the sender with notice as to why. Is it possible it was discarded for some other reason?
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
Mark,
i solved with this code:
# diff chains/builtin.py.ori chains/builtin.py 62c62 < ('max-size', LinkAction.defer, None),
('max-size', LinkAction.jump, 'reject'),
# diff rules/max_size.py.ori rules/max_size.py 47c47 < (_('The message is larger than the {} KB maximum size'),
(_('Your message was rejected because is bigger than the list max value {} KB, please reduce the message and try again'),
Em 18/04/2022 14:37, Andre de Azevedo Cunha escreveu:
Mailman-Users mailing list -- mailman-users@python.org To unsubscribe send an email to mailman-users-leave@python.org https://mail.python.org/mailman3/lists/mailman-users.python.org/ Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: https://www.mail-archive.com/mailman-users@python.org/ https://mail.python.org/archives/list/mailman-users@python.org/
![](https://secure.gravatar.com/avatar/70fb2702834d9ca44669084a9e581c0a.jpg?s=120&d=mm&r=g)
with correct return text:
# diff rules/max_size.py.ori rules/max_size.py 47,48c47,48 < (_('The message is larger than the {} KB maximum size'), < mlist.max_message_size))
(_('Your message was rejected because is bigger ( {} KB ) than the list max value, please reduce the message to bellow of {} KB and try again'), round(msg.original_size/1024.0,2),mlist.max_message_size))
Em 18/04/2022 14:59, Andre de Azevedo Cunha escreveu:
participants (2)
-
Andre de Azevedo Cunha
-
Mark Sapiro