Skip to content
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

update email handling #599

Merged

Conversation

bmartin5692
Copy link
Contributor

#598 was caused by unicode characters from the user's full name being included in the to header of the validation email.

I re-worked the email code to simplify and standardize it:

  • Email header creation moved into EmailHelpers.py as create_email_headers

    • This sets the From,To headers properly encoding any unicode, which is what caused 598.
  • Base64 encoding of the email body/template moved into EmailHelpers.py as get_emaiL_message

    • This standardizes the creation of an EmailMessage object, setting headers, and attempting the Base64 encoding, falling back to a normal email if it fails
    • As a bonus, this replaces the function I added previously 'email_rfc2822_compliance', as this solution encompasses that and is more robust
  • Moved sending code into EmailHelpers.py as send_email_message

    • Changed from sendmail to send_message since we are using an EmailMessage object now
  • Updated send_validate_message to use the new functions

  • Updated create_validate_message to use the new functions

  • Updated ForgotPasswordHandler to use the new functions

  • Updated create_reset_message to use the new functions

moloch--#598 was caused by unicode characters from the user's full name being included in the to header of the validation email.

I re-worked the email code to simplify and standardize it:
- Email header creation moved into EmailHelpers.py as create_email_headers
  - This sets the From,To headers properly encoding any unicode, which is what caused 598.
- Base64 encoding of the email body/template moved into EmailHelpers.py as get_emaiL_message
  - This standardizes the creation of an EmailMessage object, setting headers, and attempting the Base64 encoding, falling back to a normal email if it fails
  - As a bonus, this replaces the function I added previously 'email_rfc2822_compliance', as this solution encompasses that and is more robust
- Moved sending code into EmailHelpers.py as send_email_message
  - Changed from sendmail to send_message since we are using an EmailMessage object now

- Updated send_validate_message to use the new functions
- Updated create_validate_message to use the new functions
- Updated ForgotPasswordHandler to use the new functions
- Updated create_reset_message to use the new functions
@eljeffeg eljeffeg merged commit 4b82eec into moloch--:master Nov 10, 2023
2 checks passed
@eljeffeg
Copy link
Collaborator

Nice Thanks!

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

Successfully merging this pull request may close these issues.

2 participants