diff --git a/FAQ.assets/image-20240117-1.png b/FAQ.assets/image-20240117-1.png new file mode 100644 index 0000000..ab42ac2 Binary files /dev/null and b/FAQ.assets/image-20240117-1.png differ diff --git a/FAQ.assets/image-20240117-2.png b/FAQ.assets/image-20240117-2.png new file mode 100644 index 0000000..eb39673 Binary files /dev/null and b/FAQ.assets/image-20240117-2.png differ diff --git a/FAQ.md b/FAQ.md index 979347a..e6a0e9d 100644 --- a/FAQ.md +++ b/FAQ.md @@ -12,6 +12,7 @@ This page will list out quick responses, common bugs and their fixes, as well as ## After walking through [GETTING_STARTED.md](https://github.com/cs161-staff/extensions/blob/master/GETTING_STARTED.md) * [The Form Responses tab is filling, but the Roster tab is not](#the-form-responses-tab-is-filling-but-the-roster-tab-is-not) * [I need to change the name of the slack channel](#i-need-to-change-the-name-of-the-slack-channel) +* [I want to add custom comments without copy-pasting](#I-want-to-add-custom-comments-without-copy-pasting) ## Error messages * ["Student \ responded '' to DSP question in extension request, but is not marked for DSP approval on the roster. Please investigate!"](#snr) * ["Error: ('An error occurred while sending an email:', Exception(... Insufficient system storage', 'cs162ta@cs162.eecs.berkeley.edu'))"](#cs162) @@ -35,6 +36,15 @@ This page will list out quick responses, common bugs and their fixes, as well as ### I need to change the name of the slack channel >No problem! Changing the name of the slack channel where the webhook points will not affect it. You should be able to do this with no consequences. +### I want to add custom comments without copy-pasting +>You can take advantage of google sheets to do this! On a separate tab, type out any comments you want to be able to toggle off and on for any given email. +![image-20240117-1](FAQ.assets/image-20240117-1.png) + +>Back in the roster tab, create two new columns. In one of the columns, column 1, insert a checkbox. In the other column, column 2, you can use the formula `IF(\, \, "")`. If you want multiple comments you can use concatenate. +![image-20240117-1](FAQ.assets/image-20240117-2.png) + +>To include the comment, toggle on the check box. If the checkbox is unchecked, the formula above will include an empty string instead of the comment. +
### "Student \ responded '' to DSP question in extension request, but is not marked for DSP approval on the roster. Please investigate!" diff --git a/requirements.txt b/requirements.txt index 6083bec..aaa721c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ attrs==21.4.0 autopep8==1.6.0 beautifulsoup4==4.10.0 black==21.12b0 +boto3==1.0.0 bs4==0.0.1 cachetools==4.2.4 certifi==2021.10.8 diff --git a/src/email.py b/src/email.py index 205cb66..cedcb3c 100644 --- a/src/email.py +++ b/src/email.py @@ -2,6 +2,10 @@ import os from datetime import datetime, timedelta +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText +from email.utils import formataddr +from smtplib import SMTP_SSL, SMTPException from typing import List from sicp.common.rpc.mail import send_email @@ -99,7 +103,7 @@ def fmt_date(dt: datetime): body=body, ) - def send(self) -> None: + def OLDsend(self) -> None: # TODO: When 162 adds HTML support, bring back HTML emails. # html_body = Markdown().convert(self.body) # extra_headers = [("Content-Type", "text/html; charset=UTF-8")] @@ -125,3 +129,46 @@ def send(self) -> None: except Exception as e: raise EmailError("An error occurred while sending an email:", e) + + + def send(self) -> None: + PORT = 465 # For starttls + HOST = "bcop.berkeley.edu" + username = "svc-bcop-seamless-learning" + sender_email = "seamless-learning@berkeley.edu" + SENDERNAME = Environment.get(ENV_EMAIL_FROM) + receiver_email = self.to_email + cc_emails = self.cc_emails + reply_to_email = self.reply_to_email + password = "RbLgAvAcba3Ba3chbsW5VQ4Z" + SUBJECT = self.subject + # message = """\ + # Subject: Hi there + + # This message is sent from Python.""" + + BODY_TEXT = ("BCOP TEST TEST") + + msg = MIMEMultipart('alternative') + msg['Subject'] = SUBJECT + msg['From'] = formataddr((SENDERNAME, sender_email)) + msg['To'] = receiver_email + msg.add_header('reply-to', reply_to_email) + if len(cc_emails) > 0: + msg['CC'] = ",".join(cc_emails) + # Comment or delete the next line if you are not using a configuration set + # msg.add_header('X-SES-CONFIGURATION-SET',CONFIGURATION_SET) + + # Record the MIME types of both parts - text/plain and text/html. + part1 = MIMEText(self.body, 'plain') + + # Attach parts into message container. + # According to RFC 2046, the last part of a multipart message, in this case + # the HTML message, is best and preferred. + msg.attach(part1) + + with SMTP_SSL(HOST, PORT) as server: + server.login(username, password) + server.sendmail(sender_email, receiver_email, msg.as_string()) + server.close() + print("Email sent!") \ No newline at end of file