Postmark email function works in netlify dev but not on live site

Site name: https://gracious-shockley-06e0b6.netlify.app/

I have a function ( submission-created.js ) which should email me the contents of a form submission from the site. When testing locally on “netlify dev” it works great. When I deploy it to the live site it doesn’t work. It has been found by the build bots, it is run on submission with console.log showing the field submissions. I feel like I must be missing something very simple.

Here is the function : https://gist.github.com/DukeRupert/0d3d3775cd66e5d5c2845a9cdd9740fb

Here is a function log when submitting to the site in production:
3:14:25 PM: 2020-10-29T22:14:25.364Z 04e073b3-55a0-4772-855f-a4471328ff28 INFO submission created error testing
3:14:25 PM: 2020-10-29T22:14:25.365Z 04e073b3-55a0-4772-855f-a4471328ff28 INFO Name: Logan Williams
3:14:25 PM: 2020-10-29T22:14:25.365Z 04e073b3-55a0-4772-855f-a4471328ff28 INFO Email: firefly@loganwilliams.tech
3:14:25 PM: 2020-10-29T22:14:25.365Z 04e073b3-55a0-4772-855f-a4471328ff28 INFO Message: Hello world!
3:14:25 PM: 2020-10-29T22:14:25.365Z 04e073b3-55a0-4772-855f-a4471328ff28 INFO Timeline: Not important thank goodness.
3:14:25 PM: 2020-10-29T22:14:25.365Z 04e073b3-55a0-4772-855f-a4471328ff28 INFO Tell me about your budget: 3
3:14:25 PM: Duration: 40.67 ms Memory Usage: 74 MB Init Duration: 195.77 ms

1 Like

Maybe you can try adding some console.logs inside your try/catch block. This way you can tell if the send email part of your function worked on not. Let me know if that helps.

@firefly I have this exact same issue Logan - were you able to resolve it?

Hi, @barrymcgee. How are you emailing? If you are using SMTP on port 25, this is blocked by default on AWS Lambda (which is what Functions are using - search for “What restrictions apply” at that link for more information).

Hi Luke,

As with the example above, we’re not sending the email directly via the function, we’re just reaching out to the Postmark API… they then do the sending?

Barry

Hi, @barrymcgee. I didn’t notice that the emailing was being done via API. Yes, those would be HTTP requests on port 443 (as I’m assuming SSL is used) so the port 25 block would not impact these API calls at all.

Are you sure the required environment variables are being setup in the deployed Function the same way they are locally (meaning, specifically, any auth tokens required)?

Hi Luke, yes I’m sure - both API keys on dev and prod are identical.

Hi, @barrymcgee. I don’t have any “special” ability to debug the deployed Functions. They are deployed to AWS Lambda so the only way I have to debug them is to rely on the logging of the function itself.

If the function doesn’t log why the failure occurs, I’m just as in the dark as to why as you are.