def send_help_email(username:str, user_email:str, subject:str, message:str) -> bool:
"""
Sends an email to the netsoc email address containing the help data,
CC'ing all the SysAdmins and the user requesting help.
This enables us to reply to the email directly instead of copypasting the
from address and disconnecting history.
:param username the user requesting help
:param user_email the user's email address
:param subject the subject of the user's help requests
:param message the user's actual message
"""
message_body = \
"""
From: %s\n
Email: %s
%s
PS: Please "Reply All" to the emails so that you get a quicker response."""%(
username, user_email, message)
msg = EmailMessage()
msg.set_content(message_body)
msg["From"] = p.NETSOC_ADMIN_EMAIL_ADDRESS
msg["To"] = p.NETSOC_EMAIL_ADDRESS
msg["Subject"] = "[Netsoc Help] " + subject
msg["Cc"] = tuple(p.SYSADMIN_EMAILS + [user_email])
try:
with smtplib.SMTP("smtp.sendgrid.net", 587) as s:
s.login(p.SENDGRID_USERNAME, p.SENDGRID_PASSWORD)
s.send_message(msg)
except:
return False
return True
评论列表
文章目录