Skip to content

Commit

Permalink
debugging template filling and persistent env.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidEBest committed May 22, 2024
1 parent aab227c commit e4c97b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions dhrn-functions/packages/dhrn/sendmail/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ def main(args):
with open("template.html") as f:
template = Template(f.read())

filled_template = template.render(data=args)

mail = mt.Mail(
sender=mt.Address(email=MAILTRAP_SENDER_ADDRESS, name="Code For Dayton"),
to=[mt.Address(email=MAILTRAP_TO_ADDRESS)],
subject="New submission from the DHRN Screener",
text="Please enable HTML to view this message",
html=template.render(data=args),
html=filled_template,
category="Integration Test",
)
try:
client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN)
client.send(mail)
except mt.exceptions.AuthorizationError as e:
# Handle the authorization error here
return {"error": f"Mailtrap authorization error {MAILTRAP_API_TOKEN}, {MAILTRAP_SENDER_ADDRESS}, {MAILTRAP_TO_ADDRESS}", "body": args}
return {"error": f"Mailtrap authorization error {MAILTRAP_API_TOKEN}, {MAILTRAP_SENDER_ADDRESS}, {MAILTRAP_TO_ADDRESS}", "body": args, "filled_template": filled_template}

return {"body": args}
5 changes: 4 additions & 1 deletion dhrn-functions/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ packages:
web: true
webSecure: false
parameters: {}
environment: {}
environment:
MAILTRAP_API_KEY: "${MAILTRAP_API_KEY}"
MAILTRAP_SENDER_ADDRESS: "${MAILTRAP_SENDER_ADDRESS}"
MAILTRAP_TO_ADDRESS: "${MAILTRAP_TO_ADDRESS}"
annotations: {}
limits: {}

0 comments on commit e4c97b5

Please sign in to comment.