Open jensneuhaus opened 4 years ago
@jensneuhaus this part is still not cleared Have standard emails
. Since we decided that we will use saasy as email backend, there is no way we can create default templates on our side, because we require saasy setup on this. Or did I get something wrong? May I ask you to clarify?
Let me try to rethink it while typing.
saasy
for sure - thats why we made it. sassy
from saasy.utils import create_and_send_mail
context={
'first_name': 'John',
'last_name': 'Doe',
}
create_and_send_mail(
context=context,
subject='Test',
to_address="john.doe@example.org"
)
create_and_send_email
logicsaasy
email backend is set, it checks for the SAASY_API_KEY
--> if the SAASY_API_KEY
does not exist or is None, it stops handling and gives an errorsaasy
API Key exists, it sends emails using saasy. mail = saasy.create_mail({
"to_address": email,
"context": context,
"subject": subject
}
)
saasy.send_mail(mail["id"])
from saasy.utils import render_context_in_standard_template
text, html = saasy.utils.render_tontext_in_standard_template(context,subject)
# Construct an email message that uses the connection
email1 = mail.EmailMessage(
'Hello',
'Body goes here',
'from@example.com',
['to1@example.com'],
)
# Also create HTML mail, check django-saas-email and the former code in emails how it is done
email1.send() # Send the email
context
and a default file structure template
to render the text (check emails - deleted code or django-saas-emailExample template: https://github.com/pixelpassion/django-saas-email/blob/master/django_saas_email/templates/django_saas_email/email_base.html
@jensneuhaus May I ask you a question? I don’t quite understand which template to use if the saasy is not connected. Can I create a simple template and paste text from context there?
Hey @vladborisov182 - sure, sorry for not having this clear enough.
The boilerplate (or saasy
package, might be also the place to have this) should have one basic template we use (e.g. like this one).
saasy
E.g.
Hello,
{text}
{EMAIL_FOOTER} <-- Would be an ENV and in settings
context
-> text
And then we also require a small alternative text for each of the emails, e.g.
Here is your sign up verification link: {{SIGN_UP_VERIFICATION_LINK}}
Please click here to verify and setup a new password: {{PASSWORD_VERIFICATION_URL}}
This way it first renders context -> text AND then the text into a Text/HTML email.
Not sure, if this makes no sense if we rely on saasy
anyhow but its meant as a quick debug alternative.
@jensneuhaus I don't get the reasons for that. We use saasy for the emails, when we have saasy api key. When we don't have it - we rely on the developers to implement their own backend/ use existing one
I suppose IF we are going implement some emails that we're going to have in boilerplate template - we may implement fallbacks as well, but don't see much reasons to do that, because if we not using saasy, we still need to customize this part. So it still will be rewritten by devs again.
So I'd propose to first create email backend and that's it. Then if you think this should be in the template, you can assign issues on specific emails we should have in the template.
But currently, I'm confused of how this should be handled by our boileplate saasy email backend from your description. If there is default email tempalte on saasy end - it's not on our end to create it, but on saasy end.
☝️What is it? Why do we need it?
We should use
sassy
to send emails. Please prepare the logic in the following way:SAASY_API_KEY
exists, we use Saasy; if not we use standard email behavior📋 Todos
saasy
sassy
at one pointSAASY_API_KEY
exists, it should use our API to send default emails without template, usingcontext { text:BODY, header:SUBJECT }, subject=SUBJECT
, etc.simple-email-verification
simple-password-rest