def send_confirm_email(self):
"""
Send an confirm email to user. contains a link to confirm the email
confirm link is not provide by this app, a client must implement this endpoint to complete the confirmation.
"""
from server import app, mail
token = self.generate_confirm_email_token()
confirm_url = '{0}://{1}/email-confirm?token={2}'.format(app.config['SITE_PROTOCOL'],
app.config['SITE_HOST'],
token)
subject = '[{0}] Email Address Confirmation'.format(app.config['SITE_NAME'])
email_content = render_template('email-confirm.html', info={
'confirm_title': subject,
'confirm_url': confirm_url,
'site_name': app.config['SITE_NAME'],
'user_name': self.name
})
msg = Message(subject, recipients=[self.email], html=email_content)
try:
mail.send(msg)
except SMTPAuthenticationError:
raise ServerError('SMTP authentication failed', 500)
评论列表
文章目录