Skip to content
Snippets Groups Projects

Feature/comp 257 send email on signup

Merged Bjarke Madsen requested to merge feature/COMP-257-Send-Email-On-Signup into develop
2 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
17 server.sendmail(from_addr=sender_email, to_addrs=recipients, msg=message)
18 logger.debug('Successfully sent email')
19 except Exception:
20 logger.exception('Unable to send email:')
21
22
23 def send_mail(
24 contents: str,
25 subject: str = 'New user signed up for Compendium',
26 recipients: Union[str, Sequence[str]] = ''
27 ):
28 if not current_app.config['MAIL_ENABLE']:
29 logger.warning('No mail configuration, cannot send email.')
30 return
31
32 if not isinstance(contents, str):
  • 5 from sqlalchemy import select
    6 from flask import current_app
    7 from compendium_v2 import db
    8 from compendium_v2.db.auth_model import User, ROLES
    9
    10 logger = logging.getLogger(__name__)
    11
    12
    13 def _send_mail(smtp_server, port, sender_email, recipients, message):
    14
    15 try:
    16 with smtplib.SMTP(smtp_server, port) as server:
    17 server.sendmail(from_addr=sender_email, to_addrs=recipients, msg=message)
    18 logger.debug('Successfully sent email')
    19 except Exception:
    20 logger.exception('Unable to send email:')
  • Bjarke Madsen added 2 commits

    added 2 commits

    • 5540964a - Remove redundant error checks and add empty contents check
    • 0ff4c721 - pep8

    Compare with previous version

  • Mohammad Torkashvand approved this merge request

    approved this merge request

  • Bjarke Madsen added 1 commit

    added 1 commit

    Compare with previous version

  • merged

  • Bjarke Madsen mentioned in commit a41048aa

    mentioned in commit a41048aa

  • Please register or sign in to reply
    Loading