forked from sr2/cloud-api
feat: lettermint integration
This commit is contained in:
parent
58e7ae6c5c
commit
11eeddb347
5 changed files with 39 additions and 3 deletions
22
src/utils.py
22
src/utils.py
|
|
@ -1,3 +1,4 @@
|
|||
from lettermint import Lettermint, ValidationError
|
||||
from datetime import datetime, timezone
|
||||
from joserfc import jwt, jwk, errors
|
||||
|
||||
|
|
@ -38,6 +39,21 @@ async def verify_email_token(user_model, token):
|
|||
|
||||
|
||||
async def send_email(recipient: str, subject: str, body: str):
|
||||
print(recipient)
|
||||
print(subject)
|
||||
print(body)
|
||||
lettermint = Lettermint(api_token=settings.LETTERMINT_API_TOKEN.get_secret_value())
|
||||
|
||||
if settings.ENVIRONMENT.is_testing or settings.ENVIRONMENT == "local":
|
||||
recipient = "ok@testing.lettermint.co"
|
||||
|
||||
try:
|
||||
response = (
|
||||
lettermint.email.from_("noreply@sr2.uk")
|
||||
.to(recipient)
|
||||
.subject(subject)
|
||||
.text(body)
|
||||
.send()
|
||||
)
|
||||
|
||||
print(response.status_code)
|
||||
except ValidationError:
|
||||
# Error thrown if domain not approved for project
|
||||
print("Lettermint validation error")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue