Skip to content

fix and improve emailing class list aliases #3832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

milescalabresi
Copy link
Contributor

@milescalabresi milescalabresi commented Apr 23, 2025

replace sha with hashlib for python3 to fix issue with emailing class list aliases

@milescalabresi milescalabresi requested a review from kkbrum April 23, 2025 01:19
@milescalabresi milescalabresi self-assigned this Apr 23, 2025
@willgearty
Copy link
Member

willgearty commented Apr 23, 2025

Some additional ideas based on discussion:

  1. We should verify sender email addresses in mailgate.py before sending along emails:
  1. We should reject any emails from
  • a sender email address that isn't associated with an account on [subdomain].learningu.org or learningu.org

@milescalabresi milescalabresi changed the title replace sha with hashlib for python3 fix and improve emailing class list aliases May 2, 2025
@milescalabresi
Copy link
Contributor Author

We discussed a better way to do it.

  1. Catch sender's message and grab the data fields (To, From, Subject, Body, etc.)
  2. If the sender's email is not associated with an account on the site:
    a. Do not forward the email
    b. Send the user a bounce message (rate-limit once per day/week/something using something similar to dbmail.MessageRequests to track)
  3. If the sender's email is associated with an account on the site:
    a. If there is more than one such account, do some logic to identify the "right" account (options include: prefer admin > teacher > volunteer > student; choose earliest account created; send a bounce and instruct them to merge accounts), say [email protected]
    b. Use SendGrid to send an email to each recipient of the original message (To, Cc, Bcc) individually from [email protected]. We should be able to import and use the send_mail function

@willgearty
Copy link
Member

With those changes, this should also fix #3760.

# Catch sender's message and grab the data fields (To, From, Subject, Body, etc.)
data = dict()
for field in ['to', 'from', 'cc', 'bcc', 'subject', 'body']:
data[field] = message[field].split(',')
Copy link
Member

@willgearty willgearty Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to use instance.recipients to get the 'to' field

Copy link
Contributor Author

@milescalabresi milescalabresi Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good catch; added TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants