This project creates a backend for a "Contact Us" form. It uses a Gmail account to send you an e-mail on behalf of someone else, e.g. a visitor to your site.
Run this project on DataFire.io
- Go to the Integrations tab, and add a new Gmail account.
- Select the
https://www.googleapis.com/auth/gmail.sendscope. - Click "Add Account" and log into the Gmail account you want to send messages from
- Navigate to the Actions tab, and click on
contact_me - Replace
YOUR_EMAIL@gmail.comwith your own email address - Click "Deploy"
- Select
prod - Click "Deploy Project"
To run this project manually:
git clone https://github.com/DataFire-repos/contact-us-base
cd contact-us-base
npm install
datafire authenticate google_gmail
# Choose the gmail.send scope
# Edit ./actions/contact_me.js and replace YOUR_EMAIL@gmail.com with your email address
datafire serveThere is one URL for this API - POST /contact. It accepts both urlencoded and JSON content.
If you're running your project on DataFire.io, replace http://localhost:3000 with your project's host, e.g. https://project-name.prod.with-datafire.io.
<form action="http://localhost:3000/contact" method="post">
<input type="text" name="emailAddress">
<textarea name="message"></textarea>
</form>curl -X POST "http://localhost:3000/contact" \
-d 'message=hi&emailAddress=me@example.com'curl -X POST "http://localhost:3000/contact" \
-d '{"message": "hi!", "emailAddress": "me@example.com"}'
-H 'Content-Type: application/json'