Skip to content

Commit

Permalink
Merge pull request #27 from chadfawcett/release-1.0.5
Browse files Browse the repository at this point in the history
Release 1.0.5
  • Loading branch information
chadfawcett committed Feb 12, 2016
2 parents 49d5d2b + fbe696f commit 217b356
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Mailhound is a simple server side script for receiving form posts and emailing t

## Usage

### Typical Setup

```html
<form method="POST" action="http://heroku.url.com?key=ADMIN">
<input type="text" name="name" placeholder="Name">
Expand All @@ -42,6 +44,62 @@ Mailhound is a simple server side script for receiving form posts and emailing t

Make sure to update the `action` url to be your Heroku app url, and the key should be `ADMIN` or a custom key that matches your config variables.

### Main Message

The main text message of your email. This field is usually a `<textarea>` with a `name="message"` set. This will default to '**No message was provided**' if the field is ommited.

```html
<textarea name="message"></textarea>
```

### Email Subject

This field allows you to set the subject of the email. Defaults to '**Email from mailhound**'. It is not always beneficial to allow the user to specify the subjet, in this case you can simply hide the field.

```html
<!-- User defined subject -->
<input type="text" name="_subject" />

<!-- Static subject -->
<input type="hidden" name="_subject" value="New message from my website!" />
```

### Reply To

The reply to field is meant for the user's email. It allows for simply replying to the email sent to you instead of having to copy the user's address to a new email.

```html
<!-- Basic reply to field -->
<input type="email" name="_replyto" />

<!-- Option for better auto completion -->
<input type="email" name="email" />
```

### Name

This field is simply for the emailer's name.

```html
<input type="text" name="name" />
```

### CC

This field allows you for the user to specify an address to get a cc'd copy of the form.

```html
<input type="text" name="_cc" />
```

### Redirect

By default, the script redirects to the page that sent the form. If you would like to redirect the user to a specific page after the form has been sent, simply specify the url in this hidden field.

```html
<input type="hidden" name="_next" value="http://example.com/thanks" />
```

## Advanced Usage

### Custom Keys
Expand Down Expand Up @@ -78,6 +136,14 @@ The above code will result in the following appended to the end of your email me
Cell number: ### ### ####
```

### Spam Filtering
One of the downsides of having a contact form is that you will start receving lot's of spam (bots that automatically fill out forms). To combat this, mailhound supports a visually hidden field that when filled in, will silently fail. This will catch a lot of bots, keeping your inbox much cleaner.

Simply add the following to your form to prevent spam:
```html
<input type="text" name="_gotcha" style="display: none">
```

## Contributing

Please feel free to create an issue with any bugs you find or any improvements you would like to share. Pull requests for new features are also very welcome!
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"body-parser": "^1.10.2",
"express": "^4.11.1",
"mandrill-api": "^1.0.41",
"multer": "^0.1.7",
"nconf": "^0.7.1"
},
"devDependencies": {
Expand Down
4 changes: 1 addition & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var express = require('express')
var bodyParser = require('body-parser');
var multer = require('multer');
var mandrill = require('mandrill-api/mandrill');
var nconf = require('nconf');

Expand All @@ -18,7 +17,6 @@ var app = express();
// Needed for 'req.body'
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(multer());

app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
Expand Down Expand Up @@ -66,7 +64,7 @@ app.post('/', function(req, res) {
var message = {
'text': emailMessage || 'No message was provided',
'subject': req.body._subject || 'Email from mailhound',
'from_email': req.body._replyto,
'from_email': req.body._replyto || req.body.email,
'from_name': req.body.name,
'to': [
{
Expand Down

0 comments on commit 217b356

Please sign in to comment.