diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 11358ad..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -vars.py -*.csv -message.html -.DS_Store -*.pyc diff --git a/README.md b/README.md index 3c6a212..aa578ca 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ Easily send mails via SMTP and python ## Setup 1. Copy `vars.py.example` to `vars.py` -2. Setup `vars.py` with your credentials and config -3. Adapt `message.htmt` and save your contact list to `contacts.csv` +2. Setup `vars.py` with your credentials +3. Adapt `message.txt` and import `contacts.csv` ## Usage ```python mail.py``` diff --git a/mail.py b/mail.py index 052e633..4340028 100644 --- a/mail.py +++ b/mail.py @@ -1,5 +1,4 @@ import smtplib -import time from string import Template @@ -33,7 +32,7 @@ def read_template(filename): def main(): contacts = get_contacts('contacts.csv') - message_template = read_template('message.html') + message_template = read_template('message.txt') # set up the SMTP server s = smtplib.SMTP(HOST, PORT) @@ -42,7 +41,6 @@ def main(): # For each contact, send the email: for i in contacts.index: - print(f"Sending email {i+1}\n") msg = MIMEMultipart() # create a message # add in the actual person name to the message template @@ -50,11 +48,11 @@ def main(): message = message_template.substitute(contact_dict) # Prints out the message body for our sake - print(f"{message}\n") + print(message) # setup the parameters of the message msg['From'] = MY_ADDRESS - msg['To'] = contacts[MAIL_COLUMN][i] + msg['To'] = contacts["email"][i] msg['Subject'] = SUBJECT # add in the message body @@ -64,9 +62,6 @@ def main(): s.send_message(msg) del msg - if (i + 1) % WAIT_EVERY == 0: - time.sleep(DELAY_SEC) - # Terminate the SMTP session and close the connection s.quit() diff --git a/vars.py.example b/vars.py.example index bbd94a3..1904b27 100644 --- a/vars.py.example +++ b/vars.py.example @@ -1,10 +1,5 @@ -SUBJECT = '' -EMAIL_COLUMN = '' - MY_ADDRESS = 'example@domain.tld' PASSWORD = 'p4ssw0rd' HOST = 'mail.domain.tld' PORT = 587 - -WAIT_EVERY = 5 -DELAY_SEC = 0 \ No newline at end of file +SUBJECT = '' \ No newline at end of file