We've created this little package for agencies, freelancers and also webmaster who wanted to improve they're page-speed with a static page. One of the most
common problems is the little contact form every page needs. So, here it is.
Your one stop solution for:
- vue-based page
- static wordpress page (example view below)
We recommened you to use our Dockerfile to serve your node.js server application, but you can also start the application manually using plain old node.
Before starting your server you have to edit the customers.js file in the root directory.
Open your customers.js file and search the following code:
const customers = [
{
name: "Imflow Doe",
apiKey: "4ZEKvjApbYX6P7p6XY7B3",
recipients: [ "example@example.com", ]
},
]Please change name, apiKey and recipients to your own values.
The only value that identifies a customer is the API Key.
The three values required are:
| Key | Value |
|---|---|
| Name | name of the customer |
| apiKey | a random api key. Please use a sufficiently long random string. This is the only identifier for a customer. |
| recipient | email of the recipient of the email |
In case that you don't have an idea how to create API-Keys, we added a tiny API-Creator Form on our generator page here.
Create a .env file by copiing the sample cp env.sample .env and edit it to fit to your SMTP server.
You can run the service as a single docker container using the command:
docker run -d -v PATH_TO_YOUR_CUSTOMER.JS:/app/customer.js -v PATH_TO_YOUR_DOTENV:/app/.env imflow/imflow_mail:latestWe also provide a docker-compose.yml file, which uses caddy for SSL termination. Please edit the Caddyfile to use your server name and then run the stack using
docker-compose pull
docker-compose up -dYou can run the server without Docker. Simple edit the customer.js and .env files and then start the server:
npm i
node app.jsThe most simple example for an API call to send an email is the following curl command:
curl --location --request POST 'https://your-server:4300' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "John Doe",
"email": "foo@bar.com",
"msg": "My super awesome test message",
"apiKey": "HJ6kk2rZ2fYmvw9wju",
"subject": "Hey nice to see you!"
}'Please install axios using npm i axios.
A very basic version of the contact form logic looks like this:
import axios from "axios";
export default {
setup() {
const submitForm = () => {
this.submitting = true;
this.error = false;
try {
await axios.post("https://YOURSERVER.com/", {
name: this.name,
email: this.email,
msg: this.msg,
apiKey: "HJ6kk2rZ2fYmvw9wju",
subject: "New contact form",
});
this.submitting = false;
this.isSubmitted = true;
await new Promise((resolve) => setTimeout(resolve, 2500));
} catch (e) {
this.submitting = false;
this.error = true;
console.error(e);
}
}
return {
submitForm,
}
}
}A full example can be found in the vue/imflow_mail_example directory
We provide a Wordpress plugin to use on your site. This works great with the Simply Static plugin. The wordpress plugin lives in the wp subdirectory.
- Please change the URL of your server near the end of the
imflowMail.jsfile inwp/jsdirectory. - Zip the entire
wpdirectory and upload it to your wordpress site - Insert the shortcode of the contact form on any site. The customer is identified by the API key you have set on the server.
[contactform apikey="HJ6kk2rZ2fYmvw9wju" privacy_uri="https://example.com/privacy"]- (Optional) Use the Simply Static plugin to generate a static site from your wordpress site.
- Connect to a DB
Please feel free to open an issue on the github page in order to report a bug.
Pull requests are very welcome 😉
