Build a REST API to send emails from a contact form

I am a true friend of Hugo. I have now realized 3 projects with Hugo. I am
really enthusiastic. Unfortunately, it is not (yet) possible to send static
content such as the content contact form.

I’m about to write a REST API for exactly this case in Golang. The API should
be outside the Hugo applications. The contact form within one or more Hugo
applications should be able to access this API. Which requirements are
absolutely necessary? I have not programmed such a project yet. Also, I am not
so experienced in the programming language Golang. I would like to ask you to
write your thoughts on this project.

I have set up a public repo https://gitlab.com/joergklein/smtpmailer
You can open a issue.

Thank your for the help

1 Like

Have you found prior art, other projects that do what you want to do, but maybe with other languages? I don’t think contact forms are a problem anyone is having, there are lots of self-hosted and services that makes contact forms send email really easy.

Comments is hard. Everyone wants comments, because that requires some kind of database. But contact forms are handled, I’d say.

I’d make a project in Golang that handles comments. :slight_smile:

A static contact form is easy since it is just HTML. I have one on my site at https://it.knightnet.org.uk/about/contact/

In my case, I’m using Netlify’s form handler as my “API”, the form simply posts to the API endpoint.

However, a couple of observations. You might want to avoid calling it “contact.html” - I’m going to change mine. You will also want to add some anti-spam processing. I’m getting loads of spam on my form, never used to get that with Wordpress. I think the form handler filtered it out.

There are too many people in less well off countries with an Internet connection but no steady job who can earn decent money to manually spam sites like ours. It is actually making me hit the free limits on form submissions which is a pain.

So I also need to add a form handling API that is much better than the default that Netlify provide. I don’t know Go though and I’m not about to learn it. I may try using AWS Lambda since Netlify also make that available to me. Some simple Node.JS (JavaScript) should suffice to filter out cyrillic, submissions with $ signs and all caps in the subject, etc.

Alternatively, I might start by adding JavaScript to the form itself to filter at source and then I can continue to use the standard form handler.

Little off topic, but I’d suggest against an all caps filter. Some people really do type in all caps. I receive a surprising amount of qualified leads that are completely written in all caps.

4 posts were split to a new topic: Using captchas and the nature of spam

Yes, good point.