Skip to content

Conversation

@otizonaizit
Copy link
Member

After reading that smtpd will be removed from Python in the upcoming 3.12 release after a very long deprecation phase, I decided to give massmail a serious re-spin.

  • Finally have a proper Python3 rewrite. The bulk of the code was still coming from 2003 :-))
  • Have tests for everything™ (test coverage is above 95%) :-)
  • Support adding (multiple) attachments :-)
  • Make massmail a proper package :-)
  • Use aiosmtpd for testing
  • Use click for creating the CLI: this is not only much more compact than before, we now have also proper error reporting for wrong options and wrong values
  • Use rich for coloring of the output and for progress bars
  • Use email-validator for properly validate email addresses
  • Use the modern API of the email module from the standard library
  • Use the modern API of the smtplib module from the standard library
  • Drop the confusing API mixing a parameter file as argument and the body text on stdin. Now everything is an option to the CLI
  • Make massmail complain when stuff seems weird in the parameter file or in the body text
  • Now it is UTF8 everywhere: no need to restrict subject or From header to ASCII anymore!
  • Have a comprehensive testing framework, so it is trivial to add new tests for future new functionality

This PR is going to be difficult to review by looking at the diff: not a lot of the original code has survived. It is probably easier to just look at the raw files. It is just two files after all ;-)

This PR fixes #93, fixes #87, fixes #46, fixes #41, fixes #21. fixes #18, fixes #14, fixes #13, fixes #11, fixes #9, fixes #7 , fixes #6 fixes #4, fixes #2
These PRs are made obsolete by this PR: fixes #92, fixes #91, fixes #90, fixes #89, fixes #88, fixes #86, fixes #85

make massmail installable using more modern techniques:
- pyproject.toml (supports editable installation since at least
  setuptools 66.1.1, but maybe even earlier)
- automatically generate massmail script on installation
all in one commit because the rewrite was not functional in the
development stages:

- use click for the command line interface [this makes for a much more
  consistent and clear CLI]

- port to the modern interface of the email stdlib module [takes care
  automatically of encoding issues and it is way more pythonic]

- do not use stdin anymore for the body, we use required options for
  both the parameter file and the body text: no more confusion about
  which is which like in the old interface!

- line count cut by almost half :-)))

TODO:

- write a callback for checking that CLI arguments that should
  be email address are indeed email addresses!
- rewrite the tests so that they work and add more tests
- detect use of stdin -> this means we are called using the old
  interace: we can generate a good error message!
...we make a heavy use of the pytest fixture system, which makes for
much clearer and compact test code
…email body

... get_content is documented, but does not automatically handle decoding of 8bit transferred
emails. get_payload is not documented, but is used internally by the email module and it handles
correctly the decoding...
… of the email body"

This commit was based on some wrong assumptions. Actually get_content
should always take care of the proper transfer encoding. If it doesn't
there is a bug in the email module and we shouldn't try to work around
it here.

This reverts commit 3155974.
@otizonaizit otizonaizit requested review from jakobj and keszybz April 16, 2023 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants