def send_email_invite(gid, email, teacher=False):
"""
Sends an email registration link that will automatically join into a group. This link will bypass the email filter.
"""
group = api.group.get_group(gid=gid)
token_value = api.token.set_token({"gid": group["gid"], "email": email, "teacher": teacher}, "registration_token")
registration_link = "{}/#g={}&r={}".\
format(api.config.competition_urls[0], group["gid"], token_value)
body = """
You have been invited by the staff of the {1} organization to compete in {0}.
You will need to follow the registration link below to finish the account creation process.
If you believe this to be a mistake you can safely ignore this email.
Registration link: {2}
Good luck!
The {0} Team.
""".format(api.config.competition_name, group["name"], registration_link)
subject = "{} Registration".format(api.config.competition_name)
message = Message(body=body, recipients=[email], subject=subject)
mail.send(message)
评论列表
文章目录