Add a form to contact author?

Is it possible to implement a form on a post page to contact the author?

Better still, if the member is logged in, is it possible to have a button (eg, ‘contact me’) which could automatically email the author the contact information for the member?

Sounds so simple, but I have a sneaky suspicion it isn’t!

Hey @dosandco :wave:
This is definitely possible, and we’ve even got a tutorial on our site that covers the majority of how to do it:
https://ghost.org/tutorials/adding-a-contact-form/

Adding the authors email is the interesting part. User emails aren’t reachable with handlebars to prevent security risks. However with a bit of JavaScript you can drop the authors into the form in the tutorial.

After you’ve followed the tutorial add the following piece of code right after the form HTML:

<script>
if (typeof authorEmail !== 'undefined') {
  document
    .querySelector("form.contact-form")
    .setAttribute("action", `https://formspree.io/${authorEmail}`);
}
</script>

Then head over to a post in Ghost admin and open the post setting panel. Drop the following code into the Code Injection Post header:

<script>var authorEmail = "the@author.email";</script>

You’ll need to replace the@author.email with the actual authors email address. If the line above isn’t applied to the Code Injection header of the post then form submissions will be sent to the email set in the HTML.

I hope this makes sense. Any questions just ask!

Hi David,

Ever since I’ve installed formspree - it’s been sending so much spam. It’s like a honeypot for spam. I keep having to mark nearly ALL emails I receive from it as spam. Any alterrnative?

This tends to be a common trait of using regular forms on public sites. Formspree provide a “honeypot” option to remedy this. It’s a hidden field that bots will end up filling automatically, but real users will skip it. Formspree will then bin submissions that filled in the hidden field. More info can be found here: