-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
63 lines (52 loc) · 2.56 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
14 Jan 2022 fkam:
- changed util.py/getmx to return the MX with the lowest weight
12 Jan 2022 fkam:
- changed print debug lines to logging.debug() - see globalvar.py
- every module needs to do from globalvar import * and then call initlog()
10 Jan 2022 night fkam:
- added submit.py
Synopsis: cat emailfile | ./submit.py 'recipient' 'subject'
- submit a job - assuming the email text content is in emailfile
- resolved a bug in smtp.py (added QUIT) - guess that's why previously a SMTPResponseException was raised upon closing without QUIT
- tested OK with gmail server, but with Postfix target server, there's a 500 syntax error returning after a 250 success in queueing the message so ... temporarily ignore that for now as it can be delivered
10 Jan 2022 fkam:
Pmailer
Pmailer picks a email job in database, send the email directly to the recipient's MX, and then loop back to try another. If email delivery failed, it will add try count to the job and pick another one with a smaller try count but eventually will keep retrying.
To deposit a job, just insert a job row in database with "tries" = 0.
Jobs with "tries" = -1 means it's done.
Can run multiple pmailer concurrently as it does row locking so no pmailer will pick up the same job
WHEN to use pmailer?
- send only for mass mailing/notification etc
- need tight control of mail sending
- do not want to support/use full scale mailer like Postfix
TOD
- need to clean up the print debug lines
- need to do more testing with different MX for RFC822 compliance
- need to do transaction log history
- need to write a submit job script
- need to write a clean archive job script
- need to have a search script to search for job history in log
- need to support SSL/TLS
- need to support uuencode/base64 mime email content
To Setup:
- mysql -u -p < setupdb.sql
- mysql -u -p < insertdata.sql (test data)
- ./pmailer
- change orgsender in pmailer.py to your sending email
- change myhost in smtp.py to your sending host; need SPF for this host/IP
Files:
- pmailer.py - main driver
- smtp.py - smtp related modules
- util.py - utilities modules
- db.py - database related modules
- setupdb.sql - schema
- insertdata.sql - test data
9 Jan 2022 fkam:
pip3 install dnspython
python 3.6.8 - smtplib - bug sendmail() not raising any exceptions at all; so use docmd() instead
db:
- picked pymysql ... can use mysql-connector etc
- autocommit set to 0; need explicit commit in codes
- isolation -> used select ... for update (row locking)
- status field is 0 for pending jobs; 1 for completed job
- there should be another log table for job transaction history