- Upload this app to a server.
- Register for a Mailgun account (free up to 10,000 emails/month).
- Set your server's
MAILGUN_API_KEY
environment variable to your private Mailgun API key.- If this is not possible, edit the
app.js
lineconst apiKey =
- If this is not possible, edit the
- Run form2email using
npm start
- Point a DNS record to your server, e.g.
form2email.example.com
Simply add a contact form to any site as so:
<form action="https://form2email.example.com/john@anydomain.com" method="post">
<textarea type="text" name="body" placeholder="Message" required></textarea>
<input type="text" name="name" placeholder="Name" required>
<input type="text" name="company" placeholder="Company">
<input type="email" name="email" placeholder="Email" required>
<input type="tel" name="tel" placeholder="Telephone">
<input type="submit" value="SEND">
</form>
form2email will set "name" <email>
as the Reply-To address unless a reply_to
form value is specified.
Fields can be omitted or set to required as desired. form2email will add details in the footer as so:
--
name
company
email
tel
See also formspree: It works very similarly to form2email, but is more complicated, better tested, and allows for arbitrary form data. You can use their server https://formspree.io without registering, but their emails are branded.