Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102269899
email2class
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 18, 23:12
Size
1 KB
Mime Type
text/x-python
Expires
Thu, Feb 20, 23:12 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24320684
Attached To
R3683 Slides
email2class
View Options
#!/usr/bin/env python3
import argparse
import Slides.mail_helper as mailer
import Slides.class_helper as ch
config = ch.get_class_config()
parser = argparse.ArgumentParser(description='Mail to class helper')
parser.add_argument('-m', '--message', type=str,
help='File containing the message to send',
required=True)
parser.add_argument('-s', '--subject', type=str,
help='Specify the subject of the email',
required=True)
parser.add_argument('-t', '--target', type=str,
help='Specify the name of a mail box'
' to send test messages',
default="guillaume.anciaux@epfl.ch")
parser.add_argument('-u', '--username', type=str,
help='Username to log to the SMTP server',
required=True)
parser.add_argument('--markdown', action='store_true',
help='Ask to parse as markdown and generate html')
args = parser.parse_args()
students = config["students"]
message_filename = args.message
subject = args.subject
target = args.target
username = args.username
teachers = config['teachers']
assistants = config['assistants']
# read the message to send
message = open(message_filename).read()
emails = list()
# loop over students to send the email
for i, student in students.iterrows():
email = student['e-Mail']
name = student['Official name']
print("Mail to: {0}".format(email))
emails.append(email)
msg = mailer.mail(username=username, sender_email=target,
subject=subject, message=message,
copy_emails=teachers+assistants, target_emails=emails,
markdown=args.markdown)
ch.archive_email(message_filename, msg=msg)
Event Timeline
Log In to Comment