Skip to content

Commit e4c97b5

Browse files
committed
debugging template filling and persistent env.
1 parent aab227c commit e4c97b5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

dhrn-functions/packages/dhrn/sendmail/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ def main(args):
1010
with open("template.html") as f:
1111
template = Template(f.read())
1212

13+
filled_template = template.render(data=args)
14+
1315
mail = mt.Mail(
1416
sender=mt.Address(email=MAILTRAP_SENDER_ADDRESS, name="Code For Dayton"),
1517
to=[mt.Address(email=MAILTRAP_TO_ADDRESS)],
1618
subject="New submission from the DHRN Screener",
1719
text="Please enable HTML to view this message",
18-
html=template.render(data=args),
20+
html=filled_template,
1921
category="Integration Test",
2022
)
2123
try:
2224
client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN)
2325
client.send(mail)
2426
except mt.exceptions.AuthorizationError as e:
2527
# Handle the authorization error here
26-
return {"error": f"Mailtrap authorization error {MAILTRAP_API_TOKEN}, {MAILTRAP_SENDER_ADDRESS}, {MAILTRAP_TO_ADDRESS}", "body": args}
28+
return {"error": f"Mailtrap authorization error {MAILTRAP_API_TOKEN}, {MAILTRAP_SENDER_ADDRESS}, {MAILTRAP_TO_ADDRESS}", "body": args, "filled_template": filled_template}
2729

2830
return {"body": args}

dhrn-functions/project.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ packages:
3434
web: true
3535
webSecure: false
3636
parameters: {}
37-
environment: {}
37+
environment:
38+
MAILTRAP_API_KEY: "${MAILTRAP_API_KEY}"
39+
MAILTRAP_SENDER_ADDRESS: "${MAILTRAP_SENDER_ADDRESS}"
40+
MAILTRAP_TO_ADDRESS: "${MAILTRAP_TO_ADDRESS}"
3841
annotations: {}
3942
limits: {}

0 commit comments

Comments
 (0)