The god of silence, secrets and confidentiality
This is a python code to send each student's grade privately using
smtplib
to send emails from python and csv
to deal with csv file
of grades and students' names.
As you can see in sample.csv you should have a sheet like this (if your column names are different feel free to change them in code):
FIRST_NAME_COLUMN = "نام"
LAST_NAME_COLUMN = "نام خانوادگی"
STUDENT_ID_COLUMN = "شماره دانشجویی"
EMAIL_COLUMN = "ایمیل"
NOTE_COLUMN = "توضیحات"
SKIPPED_ROWS = 2
then you can fill subject.txt and body.html with the text that you want yo send as your email subject and its body. e.g.
<html>
<body dir="rtl">
<p>
با سلام<br />
دانشجوی عزیز {{ name }}<br />
نمره تمرین شما
</p>
<table>
<tbody>
{% for name, grade in grades.items() %}
<tr>
<td>{{ name }}</td>
<td>{{ grade }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<p>
در صورت هرگونه اعتراض یا مشکلی با ایمیل زیر در تماس باشید.<br />
<a href="mailto:parham.alvani@gmail.com">Pahram Alvani</a>
</p>
</body>
</html>
As you can see, this is a jinja template and you have variables that is set for each student.
Please note that you can check the emails before actually sending them with --dry-run
flag.
After fixing sheets and changing txt files run the program and enter your smtp address and after that your email address and its password in configuration file. e.g.
---
email:
server: smtp.gmail.com
username: parham.alvani@gmail.com
password: secret
Note that if you use gmail you must go to your google account and change Less secure app access here by turning on Allow less secure apps. Otherwise you need to use application-specific passwords.
You just need to install pandas using pip to run this program.
pip install .
python3 harpocrates
Here you can see some examples of emails I sent from sample csv files:
How we can contribute in @aut-ce
Do your AUT login in CLI 💻
Fundamentals of programming course resources in AUT CE.
How to actually get an intuition from what's being taught at universities, if you feel like your institution didn't do the subjects justice.
Fundamentals of Programming Laboratory Materials
How to graduate from Computer Engineering Department of Amirkabir University of Technology?