Hi
I am trying to run a script on its own for testing purposes, and i'm facing some challenges.
-
it needs yagmail, which has to be imported in a virtualenv. So currently to run the code I am going in the bash console and writing :
workon my-venv && python /home/myname/mysite/send_yagmail.py
I am wondering if there is an easier way, like using directly the console of the code itself and not the bash?
2 . I can't manage to produce my email using templates, the code is giving "AttributeError: 'NoneType' object has no attribute 'app'"
My code :
import yagmail
from flask import render_template, Flask
yag=yagmail.SMTP("login","pwd")
receiver_email = "testaddress@gmail.com"
name1 = "Smith"
body = render_template("/templates/email.html", name = name1)
yag.send(to=receiver_email, contents=body)
It seems that it's not taking the 'render_template' function, and I don't understand why, as i've used it in my main 'flask_app'.
It's showing me an error with ctx.app.update_template_context(context), and the little i've seen here, the difference is that i'm not running my app here, just a script, so i'm not sure how it translates...
Thank you for your help!