Extern an endpoint on a certain port that will securely (maybe using task queue integration) send emails received from website’s contact form.
So Hugo is a static site generator and the server is for development purposes only, so I don’t think this feature makes a lot of sense
That said, there are plenty of form solutions out there that allow you to embed forms inside static pages:
- Formspree (this seems like the best fit for your use case)
- mailjet (Referenced below as well)
Note too that many on the forums use Netlify to host their static sites—this is my personal favorite as well. Even their free tier includes some really easy-to-set-up forms.
[SOLVED] Hugo Server for Production Revisited
We use for one project Mailjet. It has an API to send emails. Maybe you can implement one of this API’s in Hugo to send emails from a contact form. If the answer yes, please send my an email.
Here is a link to the API.
Don’t forget Basin; they offer unlimited form submissions per month for free. You can do more for free with Basin than other alternatives listed in this post, and for what it’s worth I’m a happy (free) user.
Well, off course there are third party alternatives. The problem with that is that you don’t know if someone reads these emails and free plans almost never going to satisfy you. And I’m bringing this up because the implementation of a simple smtp server is no more than 50 lines of code (in python), and there are golang send mail implementations already. This way everything stays internaly within your application and free - so why don’t expose an endpoint on hugo that is configurable from config.toml to handle contact form requests?
But what you’re suggesting here has, unfortunately, an enormous overhead. Sure, writing the Go code for an email server is easy. But that’s just 5% of the work.
After that we need:
- Support the code and debug any features it brings it,
- Have users manage servers where
- Bring the security of
hugo serverup to par,
- Make the Hugo developer team responsible for very quick resolutions of security-critical bugs,
- Add additional security code to prevent misuse of Hugo’s email feature,
- Have users update and maintain their servers.
The whole point of using a 3rd party is that you don’t have to worry about stuff like this.
(By the way, I definitely understand the privacy angle of maintaining your own data. And I agree with that. But 95% of people use free email services like GMail and Outlook, which already give those companies ‘read’ ability of those emails. Unfortunately. So maintaining your own secure email service is not going to solve data privacy, unfortunately.)
I think we have done well to show you that you have many options, so please don’t summarily discount the community’s advice.
Perhaps it’s best for you to do some more research on static site generators and how they work. SSGs like Hugo generate a series of static files…
I run a bunch of static sites and so built my own solution with a generous free plan that will work for like 99% of folks using static sites:
Hope that helps. I’m a small provider but it is profitable and reliable, so I’ll be around for a while