More updates

This commit is contained in:
Erick Ruiz de Chavez 2016-09-04 23:37:34 -04:00
parent 27725d2112
commit 4369537a0d

View file

@ -1,10 +1,21 @@
# Contact
## A basic node server for sending email forms.
A basic node server for sending email forms.
[Formspree.io](https://formspree.io/) is a great free service for sending email forms, specially for static web sites like those based on Jekyll. It gives your site the ability to send emails without having to code and run your own backend server, configure SMTP services, etc. **BUT** it might *not* be the best option for everyone.
**Contact** is a super basic Node.js application that enables you to send email forms with minimal configuration. All form configuration is done in your HTML.
For me, 2 key factors drived me to create this clone:
```html
<form method="post" action="http://example.com/contact@example.com">
<input type="hidden" name="_subject" value="This is a test form" />
<input type="email" name="_from" />
<input type="text" name="first_name" />
<input type="text" name="last_name" />
<textarea name="comments"></textarea>
<input type="submit" name="Submit" />
</form>
```
This project is, in some way, a clone of a great free service: [Formspree.io](https://formspree.io/). Although Formspree is great, it might **not** be the best option for everyone; 2 key factors drived me to create this clone:
1. Setup (and maintenance) should be minimal.
Formspree is opensource and it's code is on GitHub, but the setup process is way more than a trivial task, not to mention the requirements. Requirement 1 not met.
@ -12,10 +23,6 @@ For me, 2 key factors drived me to create this clone:
1. Should allow me to send attachments.
Formspree does not allow you to send email forms with attachments (at least not at the time when this written). Requirement 2 not met.
Someone way smarter than me said, if there is nothing that solves your problem, code your solution, and so I did.
**Contact** is a super basic Node.js application that enables you to send email forms with minimal configuration and, as a bonus, it follows almost the same fields and usage as Formspree with a few differences (all of them explained bellow).
## Requirements
- Node.js v6.0.0 or greater.
@ -54,7 +61,9 @@ mailgun:
key: key-l0r3m1p5umd0l0r5174m37c0n53c737u
```
**Contact** uses **indecent.js** for loading YAML configuration files, this allows you to override the above settings based on the value of `NODE_ENV`. You can read more about that in the module site.
**Contact** uses [indecent.js][indecent] for loading its YAML configuration files, this allows you to override the above settings based on the value of `NODE_ENV`. You can read more about that in the [module documentation][indecent].
[indecent]: https://github.com/eruizdechavez/indecent.js
## Server Usage
@ -62,18 +71,7 @@ To run the server, just run `node index.js`. You can use other node runners to k
## Sending Emails
Once your server is up and running, all you need to do is create an HTML form and point it to your server. Asumming your **contact** server is running in `example.com:8081`, A form would look like this:
```html
<form method="post" action="http://example.com/contact@example.com">
<input type="hidden" name="_subject" value="This is a test form" />
<input type="email" name="_from" />
<input type="text" name="first_name" />
<input type="text" name="last_name" />
<textarea name="comments"></textarea>
<input type="submit" name="Submit" />
</form>
```
Once your server is up and running, all you need to do is create an HTML form and point it to your server.
Your form's action should point to your **contact** server using a valid email address (defined in the YAML file). If the email address is not in the whitelist the email will not be sent.