1.0.0 • Published 10 years ago
form-to-ses v1.0.0
Contact form to Amazon SES
Receive POST data and send them through Amazon SES (ideal for contact forms)
Setup
Prerequisites:
- Node.js
- An Amazon SES account
Retrieve dependencies:
npm installConfigure:
cp config.dist.json config.jsonThen edit config.json to setup your app:
region: your Amazon SES account regionaccess_key_idandsecret_access_key: your Amazon AWS credentialsfrom: the sender email address of the emails you will receive (it must be verified). You can use the[origin]placeholder, which will be replaced by the hostname of your form, or[domain]for the domain name (origin root).to: your email address(es)default_subject: used if your visitor did not provide a subject to their message (or if you did not provide asubjectfield)allowed_origins(optional): hostnames allowed to post (no port)rollbar_token(optional): your Rollbar Project Access Token (usually the post_server_item)
Start
./server.jsOr daemonize:
npm install -g pm2
PORT=3000 pm2 start server.js --name "form-to-ses" -- --colorUse
Your contact form should look like this:
<form method="post" action="http://mail.yourdomain.com/send">
<input type="hidden" name="success" value="thanks.html">
<input type="hidden" name="error" value="error.html">
<input type="text" name="name" required>
<input type="text" name="email" required>
<input type="text" name="subject">
<textarea name="message"></textarea>
<button>Send</button>
</form>If the mail is successfully sent to you, the user will be redirected to the page specified in the success input field.
If an error happens, the user will be redirected to the page specified in the error input field, with the reason as a reason parameter in the URL query. If you have plugged a Rollbar account, you will find more information there.
1.0.0
10 years ago