[gsoc-admin] email: Add subject
- From: Lasse Schuirmann <lschuirma src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gsoc-admin] email: Add subject
- Date: Sun, 11 Oct 2015 12:34:30 +0000 (UTC)
commit a7edef8f91b3a8208e2a0b0b13c9d5187b578779
Author: Lasse Schuirmann <lasse schuirmann gmail com>
Date: Sun Oct 11 14:34:06 2015 +0200
email: Add subject
No email is complete without it.
data/config.cfg | 2 ++
maillib/config.py | 5 +++--
maillib/email.py | 7 ++++++-
test_main.py | 2 ++
4 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/data/config.cfg b/data/config.cfg
index de2b1ec..810f304 100644
--- a/data/config.cfg
+++ b/data/config.cfg
@@ -29,6 +29,7 @@ path = data/templates/welcome_interns
related_to = COMMUNITY_BONDING
days_before = -3
sender = lasse schuirmann gmail com
+subject = Welcome Interns!
recipients = GSoC_Students
recipients_mail_column = mail
recipients_name_column = name
@@ -44,6 +45,7 @@ path = data/templates/foo
related_to = FINAL_EVALS
days_before = 3
sender = lasse schuirmann gmail com
+subject = Test Email
recipients = GSoC_Students
recipients_mail_column = mail
recipients_name_column = name
diff --git a/maillib/config.py b/maillib/config.py
index 9805dbb..d5f256a 100644
--- a/maillib/config.py
+++ b/maillib/config.py
@@ -86,6 +86,7 @@ class EventConfig:
def append_mail_from_section(self, section):
text = get_main_data_from_section(section)
sender = section['sender']
+ subject = section['subject']
cc = section.get('cc', '')
bcc = section.get('bcc', '')
recipients_mail_column = section['recipients_mail_column']
@@ -107,8 +108,8 @@ class EventConfig:
data_dict = {}
self.mail_templates.append(
- EmailTemplate(text, sender, recipients, data_dict,
- cc, bcc, related_to))
+ EmailTemplate(text, subject, sender, recipients,
+ data_dict, cc, bcc, related_to))
def append_ics_from_section(self, section):
ics_data = get_main_data_from_section(section)
diff --git a/maillib/email.py b/maillib/email.py
index 9d4465f..33df546 100755
--- a/maillib/email.py
+++ b/maillib/email.py
@@ -5,10 +5,11 @@ import smtplib
from email.mime.text import MIMEText
-def send_mail(text, sender, recipient, cc, bcc):
+def send_mail(text, subject, sender, recipient, cc, bcc):
mimobj = MIMEText(text)
mimobj['From'] = sender
mimobj['To'] = recipient
+ mimobj['Subject'] = subject
mimobj['CC'] = cc
mimobj['BCC'] = bcc
@@ -33,6 +34,7 @@ class Contact:
class EmailTemplate:
def __init__(self,
text,
+ subject,
sender,
recipients,
data_dict,
@@ -43,6 +45,7 @@ class EmailTemplate:
Creates a new mail template.
:param text: The text with data fields marked like {key}.
+ :param subject: Subject of the email (string).
:param sender: The mail adress of the sender (string).
:param recipients: A list of Contact objects.
:param data_dict: A dictionary to fill the text.
@@ -60,6 +63,7 @@ class EmailTemplate:
'minute': now.minute})
self.text = text
+ self.subject = subject
self.sender = sender
self.recipients = recipients
self.data_dict = data_dict
@@ -77,6 +81,7 @@ class EmailTemplate:
for recipient in self.recipients:
self.data_dict['recipient_name'] = recipient.name
send_mail(self.get_specific(),
+ self.subject,
self.sender,
recipient.pretty_email_name(),
self.cc,
diff --git a/test_main.py b/test_main.py
index 6ac7db1..69d0f49 100755
--- a/test_main.py
+++ b/test_main.py
@@ -10,3 +10,5 @@ if __name__ == '__main__':
print(c.mail_templates[0].get_specific())
print("TO BE SENT ON:")
print(c.mail_templates[0].date)
+ print("SUBJECT:")
+ print(c.mail_templates[0].subject)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]