1
0
Fork 0
forked from sr2/cloud-api

feat: lettermint integration

This commit is contained in:
Chris Milne 2026-06-22 12:01:58 +01:00
parent 58e7ae6c5c
commit 11eeddb347
5 changed files with 39 additions and 3 deletions

View file

@ -36,6 +36,8 @@ class Config(CustomBaseSettings):
DATABASE_HOSTNAME: str = "localhost"
DATABASE_CREDENTIALS: SecretStr = SecretStr(":")
LETTERMINT_API_TOKEN: SecretStr = SecretStr("")
settings = Config()

View file

@ -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")