Skip to content

Commit

Permalink
see Changelog v 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerjoss committed Sep 27, 2022
1 parent 4271199 commit 551eb73
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 22 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.1.1
## 26/09/2022

1. [](#new)
* Add Option Delay
* read Config (SMTP Server, user, pass ... from yaml config file)

# v0.1.0
## 20/07/2022

Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## bulkmail.py: send bulk email to recipients in RecListFileName

This Program is a bulk Mailer, written in Python 3, intended exactly for what the name indicates:
Sending Mail to a List of recipients, but, as opposed to the standard CC Feature from conventinal MUA's, each individual Mail ist personalised,
Sending Mail to a List of recipients, but, as opposed to the standard CC Feature from conventional MUA's, each individual Mail ist personalised,
which means, each Recipient is addressed by his/her first Name.
Additionally, there is an Option 'nice' which can be used to make the Text even more nice (by using 'Liebe(r) XYZ' instead of 'Hallo XYZ').
And, yes, this nice Approach is even gender sensitive :-)
For a History about Develompment, see the following [Blog Post](https://hoernerfranzracing.de/werner/blog/spam-schleuder-version-2-0).
For a History about Develompment, see [this Blog Post](https://hoernerfranzracing.de/werner/blog/spam-schleuder-version-2-0).

This is an improved Version from this [original gist](https://gist.github.com/wernerjoss/9ba0d815bb91d043f929d98670f99064).
After some more improvements and future plannings (see TODO) I decided to make a real project out of it.
Expand Down Expand Up @@ -37,7 +37,5 @@ add Attach File Option 11.03.18
fix some bugs 18.03.18

## TODO:
- provide Option for configurable Delay between sent Mails to avoid possible Restrictions from SMTP Mailers w.r. to max. No# of sent Mails per Hour (or Day)
- Localisation (say 'Hallo' or 'Hello', 'Liebe(r)' or 'Dear' to Recipients...)
- move Configuration to separate yaml or json file
- enable optional encryption for recipients from local keyring
16 changes: 12 additions & 4 deletions bmgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
QVBoxLayout, QWidget, QFileDialog)

from PyQt5.QtCore import QProcess
import sys
import sys, os
from PyQt5 import QtCore, QtGui, QtWidgets
import bmgui_layout

Expand Down Expand Up @@ -36,21 +36,29 @@ def start_process(self):
self.p.readyReadStandardError.connect(self.handle_stderr)
self.p.stateChanged.connect(self.handle_state)
self.p.finished.connect(self.process_finished) # Clean up once complete.
ArgList = ['bulkmail.py']
expath = os.path.abspath(os.path.dirname(__file__))
exfile = expath + '/bulkmail.py' # CLI Version must reside in same Dir as GUI Version !
ArgList = [exfile]
if (self.checkBox.isChecked() == True):
ArgList.append('-s')
if (self.checkBox_2.isChecked() == True):
ArgList.append('-l')
if (self.checkBox_3.isChecked() == True):
ArgList.append('-n')
Delay = 0
if (self.spinBox.value() > 0):
Delay = self.spinBox.value()
# self.message("Delay:" + str(Delay))
ArgList.append('-d')
ArgList.append(str(Delay))
ArgList.append('-r')
ArgList.append(self.RecFile)
ArgList.append('-m')
ArgList.append(self.MsgFile)
if (len(self.Attachment) < 1):
if (len(self.Attachment) > 1):
ArgList.append('-a')
ArgList.append(self.Attachment)
# print(ArgList)
print(ArgList)
self.p.start("python3", ArgList) # JEDES arg extra !!

def openAttachmentDialog(self):
Expand Down
9 changes: 8 additions & 1 deletion bmgui_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setupUi(self, MainWindow):
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 1041, 80))
self.horizontalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 1281, 80))
self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
Expand All @@ -32,6 +32,12 @@ def setupUi(self, MainWindow):
self.checkBox_3 = QtWidgets.QCheckBox(self.horizontalLayoutWidget)
self.checkBox_3.setObjectName("checkBox_3")
self.horizontalLayout.addWidget(self.checkBox_3)
self.spinBox = QtWidgets.QSpinBox(self.horizontalLayoutWidget)
self.spinBox.setObjectName("spinBox")
self.horizontalLayout.addWidget(self.spinBox)
self.label = QtWidgets.QLabel(self.horizontalLayoutWidget)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(10, 100, 241, 40))
self.pushButton.setObjectName("pushButton")
Expand Down Expand Up @@ -61,6 +67,7 @@ def retranslateUi(self, MainWindow):
self.checkBox.setText(_translate("MainWindow", "Simulate"))
self.checkBox_2.setText(_translate("MainWindow", "Create Log File"))
self.checkBox_3.setText(_translate("MainWindow", "Nice"))
self.label.setText(_translate("MainWindow", "Delay [s]"))
self.pushButton.setText(_translate("MainWindow", "Select Recipients List File"))
self.pushButton_2.setText(_translate("MainWindow", "Select Message File"))
self.pushButton_3.setText(_translate("MainWindow", "Send Mail"))
Expand Down
12 changes: 11 additions & 1 deletion bmgui_layout.ui
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<rect>
<x>10</x>
<y>10</y>
<width>1041</width>
<width>1281</width>
<height>80</height>
</rect>
</property>
Expand All @@ -45,6 +45,16 @@
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox"/>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Delay [s]</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton">
Expand Down
49 changes: 37 additions & 12 deletions bulkmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
# ....add Attach File Option 11.03.18
# ....fix some bugs 18.03.18

import getopt, sys
import getopt, os, sys
import smtplib
from email.utils import formatdate
import datetime
import time, datetime
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
import codecs
import gender_guesser.detector as gender_detector
import yaml

def send_email(FROM, TO, SUBJECT, TEXT, att_file):

Expand Down Expand Up @@ -61,18 +62,36 @@ def send_email(FROM, TO, SUBJECT, TEXT, att_file):
LogFile.write(logtext)

def usage(progname):
print('usage: %s [-l -s -n] -r <RecListFileName> -m <MsgFileName> -a <AttachFileName>' % progname)
print('usage: %s [-l -s -n -d Delay] -r <RecListFileName> -m <MsgFileName> -a <AttachFileName>' % progname)
print('(-l = create Logfile, -s = Simulate, -n = Nice)')
sys.exit(2)

# Config (global variables):
FROM = 'George Bush <[email protected]>'
# your smtp server credentials:
smtp_server = "smtp.whitehouse.gov"
user = "ghwbush"
pwd = "obama"

# ....Defaults:
# read config from yaml file:
cfgpath = os.path.abspath(os.path.dirname(__file__))
try:
cfgfile = cfgpath + '/bulkmail.yaml' # config file must reside in same Dir as Program !
with open(cfgfile, "r") as configfile:
cfg = yaml.load(configfile, Loader=yaml.FullLoader)
configfile.close()
except: # Defaults:
print("Warning: Config File not found, using Defaults (which will most likely NOT work!")
cfg = {
'FROM': 'George Bush <[email protected]>',
'smtp_server': 'smtp1.whitehouse.gov',
'user': 'gbush',
'pwd': 'obama'
}

# print('FROM:', cfg['FROM'])
# print('smtp_server:', cfg['smtp_server'])
# print('user:', cfg['user'])
# print('pwd:', cfg['pwd'])
# sys.exit(0)

FROM = cfg['FROM']
smtp_server = cfg['smtp_server']
user = cfg['user']
pwd = cfg['pwd']

Simulate = False # nomen est omen :)
Nice = False # True: Anrede 'Liebe(r)' statt 'Hallo' :)
Expand All @@ -86,10 +105,11 @@ def usage(progname):
RecListFileName = ''
MsgFileName = ''
AttachFileName = ''
Delay = 0
try:
progname = sys.argv[0]
argv = sys.argv[1:] # wichtig !
opts, args = getopt.getopt(argv,"lsnhr:m:a:",["RecListFileName=","MsgFileName=","AttachFileName="])
opts, args = getopt.getopt(argv,"lsnhd:r:m:a:",["RecListFileName=","MsgFileName=","AttachFileName=","Delay="])
#print ('opts',opts)
#print ('argv',argv)
except getopt.GetoptError as err:
Expand All @@ -104,6 +124,9 @@ def usage(progname):
MsgFileName = arg
elif opt in ("-a", "--AttachFileName"):
AttachFileName = arg
elif opt in ("-d", "--Delay"):
Delay = int(arg) # wichtig: type conv !
# print ('Delay', Delay)
elif opt == '-l':
CreateLogFile = True
# print ('CreateLogFile')
Expand Down Expand Up @@ -185,6 +208,8 @@ def usage(progname):
print('Message %d from %s has been sent to: %s' % (lineNum, MsgFileName, TO))
else:
print('Message %d from %s would be sent to: %s' % (lineNum, MsgFileName, TO))
if (Delay > 0):
time.sleep(Delay)
lineNum += 1
LogMsg += line + '\n'
if CreateLogFile:
Expand Down
4 changes: 4 additions & 0 deletions bulkmail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM: George Bush <[email protected]>
pwd: obama
smtp_server: smtp.whitehouse.gov
user: ghwbush

0 comments on commit 551eb73

Please sign in to comment.