def sendNewsletter(nl_id):
    nl = Newsletter.query.get_or_404(nl_id)
    users = db.session.query(User).filter(User.newsletter == True).all()

    mailingList = []
    for u in users:
        mailingList.append(u.email)

    # print('Mailing List', file=sys.stderr)
    # print(mailingList, file=sys.stderr)
    # print(len(mailingList),file=sys.stderr)

    if len(mailingList) > 0:
        msg = Message(nl.title,
                      sender=current_app.config['MAIL_USERNAME'],
                      recipients=mailingList)

        url = '<a href="' + str(url_for('users.account',
                                        _external=True)) + '" >Here</a> '
        footer = '<br> <br> Are you no longer interested in the Newsletter? Just sign off '
        msg.body = ''
        msg.html = nl.content + footer + url
        # print(url, file=sys.stderr)

        mail.send(msg)
def sendEMailToAdmin(mailFrom, nameFrom, text):
    msg = Message('Contact Message form ' + nameFrom +
                  ' to pandalikeInvesting.com',
                  sender=mailFrom,
                  recipients=[current_app.config['MAIL_USERNAME']])
    msg.body = "The user: "******" wrote to pandalikeInvesting.com: " + text
    mail.send(msg)
def sendActivateEMail(user):
    token = user.get_reset_token()
    msg = Message('Activate Account Mail',
                  sender=current_app.config['MAIL_USERNAME'],
                  recipients=[user.email])
    msg.body = f''' Your account was created. To activate your account, visit the following link:
{url_for('users.activate', token = token, _external = True)}

If you did not make this request, then simply ignore this E-Mail amd no changes will be made.
'''
    mail.send(msg)
def sendResetEMail(user):
    token = user.get_reset_token()
    msg = Message('Password Reset Request',
                  sender=current_app.config['MAIL_USERNAME'],
                  recipients=[user.email])
    msg.body = f''' To reset your password, visit the following link:
{url_for('users.reset_token', token = token, _external = True)}

If you did not make this request, then simply ignore this E-Mail amd no changes will be made.
'''
    mail.send(msg)
Esempio n. 5
0
def send_reset_email(user):
    token = user.get_reset_token()
    msg = ExternalMessage('Password Reset Request',
                sender='*****@*****.**', \
                recipients=[user.email])
    msg.body = f"""To reset your password, visit the following link:
{url_for('users.reset_token', token=token, _external=True)}

If you did not make this request, then simply ignore this email, and no changes will be made to your account.
This link will expire 15 minutes after the request is made.
"""
    mail.send(msg)