I realized when I was in the middle of writing my previous post that the only way to contact me from this site is through Twitter. (Ghost doesn't have contact forms built in.) That's no good for anyone who's not on Twitter, or who doesn't want to send a message that's visible to the general public – probably most people.
There are several embedded form services available, like Typeform, Formspree, and Google Forms. Glutton for punishment that I am, of course, I'd rather roll my own.
So on Christmas day I sat down and whipped up a little form processing script that can receive a form submission and send me an email containing whatever message is filled into the form.
In a short afternoon, I managed to get it to work, although it's not at all elegant. I set up a form on a test site, submitted a test message and got the email I expected. You can find the first alpha version on GitHub.
So far, it only works by the form's submit action, which takes the user to a plain white screen on the form processing server with the results of their submission: either "Send succeeded." Or "Send Failed" with the reason for the failure.
Before I can actually use it on this site, I'll need to add a few things to make it a little more user-friendly.
- Instead of using the server's built-in sendmail function, I need it to send over a secure SMTP connection.
- The form should submit by AJAX so the user isn't taken away from the page they were looking at, and any failures can be re-interpreted in a more user-friendly way to allow for correction and another try.
- It's probably not good to keep a wide-open mail sender floating out there on the web. I'll need to implement some kind of check so the form processor only accepts submissions from legetimate web pages. (Form spam is bad enough without allowing bogus forms to send me mail, too!)
None of these are particularly hard. Maybe by the new year, I'll have it working. Once that happens, I'll be able to put up a contact page here. I can't wait to hear from you.