Sending mail with PHP through SendGrid from web form - where are the logs?

Trying to get a webform I have for contact working the way I had it when on Heroku.

I set up a new SendGrid account, got an API key and now using it to send the email through a web form. Had no luck. Would like to try and diagnose the error, but I’m not seeing any logs mentioned in the service’s page, maybe I’m missing something obvious? The only logs I see are the ones at the time of deploy.

Am I doing this the right way, at all?

Your input is kindly appreciated.

Hi John,

Thanks for reaching out.

This doesn’t sound like a Render issue, but we can try and offer some pointers, but I think we’d need some more information.

Please could you share some specific details of the issue you are experiencing that may help us troubleshoot it with you, e.g. any logs/errors/output, service name/ID, reproduction steps, etc. If you don’t want to share these details on the community forum, please feel free to raise a ticket from the “Contact Support” link at the bottom of the Dashboard.

Thanks

Alan

Thanks, Alan.

Yes, you are right, I don’t think this is a Render issue. I used the code in the usage examples from SendGrid, and if I could see if the errors, I think it would be enough? (for example, this requires loading either Composer or a specific SendGrid library, if this fails, mail doesn’t get sent)

Is there a way I can check application logs on the free plan?

Sorry, this might be something very obvious, but I’m still new on the interface, so might just be missing it.

Deploy/Build logs are shown by clicking the “Deploy” links in the “Events” tab of a service.

Runtime logs are shown in the “Logs” tab of a service.

Alan

Interesting. I don’t have a “Logs” tab, they do appear in two other services that I’ve deployed. Could it be because I deployed those using a Blueprint, contrary to this one?

How can I create a Blueprint for it then? I complains for lack of existence of the render.yml file, though while I was looking into the quick start guides, I could only find PHP-Laravel examples, nothing with plain PHP. Is there something out of this I can use?

If you don’t have a “Logs” tab, it sounds like you’re deploying Static Sites, which have no “backend”, they just serve static html/css/etc files that you provide it.

PHP on Render requires Docker, you wouldn’t need a Blueprint initially to try and get your app running.

Alan

Yes, you are correct. I’m deploying a static site, with no backend.

The only “dynamic” part of the website is the contact form, which is in PHP, and it’s only there for the mail form, that’s the only reason PHP is being used.

That’s why at first (well, now) it deployed correctly as a Static Site (with the exception of the mailform).

So I thought that if I deployed it with a Blueprint, it would somehow pick up that it needed PHP, but when I did so it started complaining about not having a render.yaml file. So I thought I’d get one, from the examples in the docs.

Looking into the guides, I saw the only example that includes PHP is PHP Web App with Laravel and Docker, which seemed a bit overkill to get a mailform going, but I don’t know if there’s any simpler way of getting the SendGrid PHP libraries to load.

What is my best option, to try to run it with those PHP-Laravel instructions, or would I be looking at having to get rid of the mailform?

Thanks for your help.

The PHP app would need to be a separate Web Service that had an endpoint for the form to submit to. As before, PHP on Render requires Docker, our docs example is for a Laravel setup, but that doesn’t mean you have to use Laravel, you can use whichever PHP Docker image and a workflow/framework (or plan PHP) you are familiar with.

If you don’t want the complication of Docker, maybe a small Node or Python app on a Native Environment would be more straightforward.

Although, if you are intending this Web Service to only be an endpoint for the contact form to send email, there are other considerations. If you plan to use a free instance type, it will spin down, which would likely make each form submission appear slow as the service would need to spin back up to take the request. To have the service run 24/7 (not spin down), it would need to be a paid instance type.

Depending on the frequency of contact form submissions you expect, other options may be available outside of Render, e.g. serverless functions or form submission service.

Alan

Thank you, Alan. You have given me a good rundown of the options I have available, so it’s a question of considering them now. I think this is what I needed to hear:

you can use whichever PHP Docker image and a workflow/framework (or plan PHP) you are familiar with.

If it’s just a question fo experimenting with the Docker image and the build commands, then it won’t be a problem. I’ll try and start with the render.yml file that is shown in the examples and build up from there. Now I know what options I have, and may even take a different one, but this time, informed.

Thank you for the help through PM, really helped getting things going, do appreciate your concern.

All the best!

No problem at all, hope you get up and running soon.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.