aspp / massmail Goto Github PK
View Code? Open in Web Editor NEWScript to send mass mail
Script to send mass mail
Since Python3.3, smtplib supports the with
statement (https://docs.python.org/3.5/library/smtplib.html). This should be used to make sure the QUIT
statement is automatically executed with the script exits. A workaround for older versions should be provided.
Instead of f = open...
one should use the context manager with open .. as f:
Old style formatting using the %
syntax should be replace with new style formatting via .format
, see e.g., https://pyformat.info/
There's no reason to use anything except utf-8...
This should prevent cough user cough error sending an email with mismatching subject line.
The -f
options allows for fake runs, allowing the user to check the email headers. The email body however is not human readable.
Make sure the FROM address is not going to be sent an email, even if in the parameter file.
Massmail should be converted to Python3, while maintaining backwars compatibility with Python2. This requires special attention to how unicode is currently handled.
massmail's source should respect the PEP8 guidelines (https://www.python.org/dev/peps/pep-0008/).
In a dedicated function, use re.match() to check the validity of a given email address. The function can then be called to test the validity of the FROM parameter, as well as for every addresses extracted from the parameter file. It should use a variant of the following regex (from: https://www.scottbrady91.com/Email-Verification/Python-Email-Verification-Script):
import re
addressToVerify ='[email protected]'
match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', addressToVerify)
if match == None:
print('Bad Syntax')
raise ValueError('Bad Syntax')
To avoid accidentally sending ill-formated emails, the default behaviour should be to not send the emails, but only print header and body to stdout. A fake option exists at the moment (-f
). One should make the fake run the default, and introduce a positive version of the command line argument.
The return value from programs is an integer between 0 and 255, and 1 should be used as "generic error". Fix the return value.
Right now we can set Bcc but can not set Cc.
Nowadays SMTP servers are more and more strict about how many emails you can send within a session and within a certain time. We should support this in massmail. We need two things:
Both things should be controllable with a command-line switch, both off by default.
The script should be refactored into functions to allow for proper testing.
Line 165 in massmail.py: exit() for interactive use should be replaced with sys.exit()
The syntax for using keyword arguments is the mail should be made sure to be consistent, i.e.,
$
should either be followed by a keyword and a closing $
as in $NAME$
$
, i.e., to write $
in the mail one would need to write $$
If the mail text violates any of these conditions, the program should print an informative error message and exit. Users should be able to override this check by providing a special command line argument.
It's not an error, the return value (according e.g. to gnu program specifications) to be 0.
Replacing the keywords one after another requires either additional escaping of $ or should be done at the same time for all keywords.
(do we need it all?)
The argparse module (https://docs.python.org/3.5/library/argparse.html) provides more flexible parsing of command line arguments. We should use this intead of getopt.
docopt simplifies the parsing of commandline arguments and is easier to use than getopt.
The date stated in the copyright statement is outdated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.