JangoMail can pull the data from a web database/web server in real time and then send a personalized mass email to email addresses in the database. Additionally, JangoMail can synchronize data (unsubscribes/bounces/clicks/opens and more) with your web database.
You can create a database connection that GETs or POSTs any arbitrary data via forms, querystring, or headers to your server as long as your server then responds with a JSON array of data back.The JSON array of data returned (see example below) must include 1 emailaddress column and anything else you want to include. If there are multiple email address columns, we will use the first one.
How to Add a Database to JangoMail
- Set up a web server to allow JangoMail to connect.
- Publish some sort of API. This can be as simple as a text file.
- This API will set the parameters of connecting to and pulling data from the database.
- Once your web server/web database is setup, you can create a new database connection in JangoMail.
- Go to Lists → Databases →click ADD A DATABASE.
- Fill in the proper values:
- Click SAVE DATABASE.
- Click Test to verify everything is working.
Sample ASPX Page
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
protected override void OnLoad(EventArgs e)
if (Request.Headers["apikey"] != "XXXXXXXXXX")
Response.StatusCode = 403;
Response.Write("No Soup For You");
if (Request.QueryString["type"] == "Users")
using (SqlConnection conn = new SqlConnection("Your connection string"))
SqlCommand command = new SqlCommand("Your SQL select statement", conn);
var rdr = command.ExecuteReader();
List<Dictionary<string, object>> ret = new List<Dictionary<string, object>>();
var dict = new Dictionary<string, object>();
for (int i =0; i < rdr.FieldCount;i ++)
string name = rdr.GetName(i);
dict[name] = rdr[i];
Response.ContentType = "application/json";
Response.StatusCode = 500;
Response.Write("Invalid query type");
- In our example, we secure our site with an apikey which is passed in as a Header. If the apikey does not match, we fail the connection with an error message.
- if (Request.Headers["apikey"] != "XXXXXXXXXX")
- We then pass in a Query string to tell the connection what query to run. If the query string does not match, we fail the connection with an error message.
- if (Request.QueryString["type"] == "Users")
- If both the headers and query strings match, then we run the query provided.
- SqlCommand command = new SqlCommand("Your SQL select statement", conn);
- With this set up, we can use the same site and set up multiple database connections by providing different headers and\or query strings to run different SQL statements.