Ejemplo n.º 1
0
def send_new_donation(user, donation):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/new_donation") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), {
                "user": user,
                "root": _cfg("protocol") + "://" + _cfg("domain"),
                "your_name": _cfg("your-name"),
                "amount": currency.amount("{:.2f}".format(
                    donation.amount / 100)),
                "frequency": (" per month"
                    if donation.type == DonationType.monthly else ""),
                "comment": donation.comment or "",
            })))
    message['Subject'] = "New donation on fosspay!"
    message['From'] = _cfg("smtp-from")
    message['To'] = "{} <{}>".format(_cfg("your-name"), _cfg("your-email"))
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [_cfg('your-email')], message.as_string())
    smtp.quit()
Ejemplo n.º 2
0
def send_declined(user, amount):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/declined") as f:
        message = MIMEText(
            html.parser.HTMLParser().unescape(
                pystache.render(
                    f.read(),
                    {
                        "user": user,
                        "root": _cfg("protocol") + "://" + _cfg("domain"),
                        "your_name": _cfg("your-name"),
                        "amount": "{:.2f}".format(amount / 100),
                    },
                )
            )
        )
    message["Subject"] = "Your monthly donation was declined."
    message["From"] = _cfg("smtp-from")
    message["To"] = user.email
    smtp.sendmail(_cfg("smtp-from"), [user.email], message.as_string())
    smtp.quit()
Ejemplo n.º 3
0
def send_password_reset(user):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/reset-password") as f:
        message = MIMEText(
            html.parser.HTMLParser().unescape(
                pystache.render(
                    f.read(),
                    {
                        "user": user,
                        "root": _cfg("protocol") + "://" + _cfg("domain"),
                        "your_name": _cfg("your-name"),
                        "your_email": _cfg("your-email"),
                    },
                )
            )
        )
    message["Subject"] = "Reset your donor password"
    message["From"] = _cfg("smtp-from")
    message["To"] = user.email
    smtp.sendmail(_cfg("smtp-from"), [user.email], message.as_string())
    smtp.quit()
Ejemplo n.º 4
0
def send_declined(user, amount):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    message = MIMEText(
        render_template("emails/declined",
                        user=user,
                        root=_cfg("protocol") + "://" + _cfg("domain"),
                        your_name=_cfg("your-name"),
                        amount=currency.amount("{:.2f}".format(amount / 100))))
    message['Subject'] = "Your monthly donation was declined."
    message['From'] = _cfg("smtp-from")
    message['To'] = user.email
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [user.email], message.as_string())
    smtp.quit()
Ejemplo n.º 5
0
def send_password_reset(user):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    message = MIMEText(
        render_template("emails/reset-password",
                        user=user,
                        root=_cfg("protocol") + "://" + _cfg("domain"),
                        your_name=_cfg("your-name"),
                        your_email=_cfg("your-email")))
    message['Subject'] = "Reset your donor password"
    message['From'] = _cfg("smtp-from")
    message['To'] = user.email
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [user.email], message.as_string())
    smtp.quit()
Ejemplo n.º 6
0
def send_declined(user, amount):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/declined") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), {
                "user": user,
                "root": _cfg("protocol") + "://" + _cfg("domain"),
                "your_name": _cfg("your-name"),
                "amount": currency.amount("{:.2f}".format(amount / 100))
            })))
    message['Subject'] = "Your monthly donation was declined."
    message['From'] = _cfg("smtp-from")
    message['To'] = user.email
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [user.email], message.as_string())
    smtp.quit()
Ejemplo n.º 7
0
def send_password_reset(user):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/reset-password") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), {
                "user": user,
                "root": _cfg("protocol") + "://" + _cfg("domain"),
                "your_name": _cfg("your-name"),
                "your_email": _cfg("your-email")
            })))
    message['Subject'] = "Reset your donor password"
    message['From'] = _cfg("smtp-from")
    message['To'] = user.email
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [user.email], message.as_string())
    smtp.quit()
Ejemplo n.º 8
0
def send_cancellation_notice(user, donation):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    message = MIMEText(
        render_template(
            "emails/cancelled",
            user=user,
            root=_cfg("protocol") + "://" + _cfg("domain"),
            your_name=_cfg("your-name"),
            amount=currency.amount("{:.2f}".format(donation.amount / 100)),
        ))
    message['Subject'] = "A monthly donation on ShleePay has been cancelled"
    message['From'] = _cfg("smtp-from")
    message['To'] = f"{_cfg('your-name')} <{_cfg('your-email')}>"
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [_cfg('your-email')], message.as_string())
    smtp.quit()
Ejemplo n.º 9
0
def send_cancellation_notice(user, donation):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    with open("emails/cancelled") as f:
        message = MIMEText(html.parser.HTMLParser().unescape(\
            pystache.render(f.read(), {
                "user": user,
                "root": _cfg("protocol") + "://" + _cfg("domain"),
                "your_name": _cfg("your-name"),
                "amount": currency.amount("{:.2f}".format(
                    donation.amount / 100)),
            })))
    message['Subject'] = "A monthly donation on fosspay has been cancelled"
    message['From'] = _cfg("smtp-from")
    message['To'] = "{} <{}>".format(_cfg("your-name"), _cfg("your-email"))
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [_cfg('your-email')], message.as_string())
    smtp.quit()
Ejemplo n.º 10
0
def send_new_donation(user, donation):
    if _cfg("smtp-host") == "":
        return
    smtp = smtplib.SMTP(_cfg("smtp-host"), _cfgi("smtp-port"))
    smtp.ehlo()
    smtp.starttls()
    smtp.login(_cfg("smtp-user"), _cfg("smtp-password"))
    message = MIMEText(
        render_template(
            "emails/new_donation",
            user=user,
            root=_cfg("protocol") + "://" + _cfg("domain"),
            your_name=_cfg("your-name"),
            amount=currency.amount("{:.2f}".format(donation.amount / 100)),
            frequency=(" per month"
                       if donation.type == DonationType.monthly else ""),
            comment=donation.comment or ""))
    message['Subject'] = "New donation on ShleePay!"
    message['From'] = _cfg("smtp-from")
    message['To'] = f"{_cfg('your-name')} <{_cfg('your-email')}>"
    message['Date'] = format_datetime(localtime())
    smtp.sendmail(_cfg("smtp-from"), [_cfg('your-email')], message.as_string())
    smtp.quit()
Ejemplo n.º 11
0
from fosspay.app import app
from fosspay.config import _cfg, _cfgi

import os

app.static_folder = os.path.join(os.getcwd(), "static")

import os

if __name__ == '__main__':
    app.run(host=_cfg("debug-host"), port=_cfgi('debug-port'), debug=True)