API
The JangoMail API is a web service that allows you to control your JangoMail account programmatically via an HTTP POST, an HTTP GET or an XML based SOAP call. JangoMail uses SOAP and WSDL standard so you can code in your favorite environment – Java, Perl, Ruby, Python, PHP, Visual Studio, .Net – and many more. And, our version 2 API available at https://api-v2.jangomail.com features RESTful services.
Our API offers an extensive set of methods which can be used to send and report on broadcast and transactional messages. Use our API to send mass email messages to a list, one-to-one messages to a single recipient or an ad hoc transactional message (welcome message, password reset, etc.). The API can return reporting data in XML, string or .NET data set formats.
cURL
Python
Java
Swift+Alamofire
Ruby
cURL
curl -X "POST" "https://api.jangomail.com/api.asmx/SendMassEmail" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "ToGroups=" --data-urlencode "ToGroupFilter=" --data-urlencode "Subject=" --data-urlencode "Options=" --data-urlencode "ToOther=" --data-urlencode "FromName=" --data-urlencode "Password=" --data-urlencode "Username=" --data-urlencode "MessageHTML=" --data-urlencode "ToWebDatabase=" --data-urlencode "FromEmail=" --data-urlencode "MessagePlain="
Python
# Install the Python Requests library: # 'pip install requests' import requests def send_request(): # SendMassEmail # POST https://api.jangomail.com/api.asmx/SendMassEmail try: response = requests.post( url="https://api.jangomail.com/api.asmx/SendMassEmail", headers={ "Content-Type": "application/x-www-form-urlencoded", }, data={ "ToGroups": "", "ToGroupFilter": "", "Subject": "", "Options": "", "ToOther": "", "FromName": "", "Password": "", "Username": "", "MessageHTML": "", "ToWebDatabase": "", "FromEmail": "", "MessagePlain": "", }, ) print('Response HTTP Status Code: {status_code}'.format( status_code=response.status_code)) print('Response HTTP Response Body: {content}'.format( content=response.content)) except requests.exceptions.RequestException: print('HTTP Request failed')
Java
import java.io.IOException; import org.apache.http.client.fluent.*; import org.apache.http.entity.ContentType; public class SendRequest { public static void main(String[] args) { sendRequest(); } private static void sendRequest() { // SendMassEmail (POST ) try { // Create request Content content = Request.Post("https://api.jangomail.com/api.asmx/SendMassEmail") // Add headers .addHeader("Content-Type", "application/x-www-form-urlencoded") // Add body .bodyForm(Form.form() .add("ToGroups", "") .add("ToGroupFilter", "") .add("Subject", "") .add("Options", "") .add("ToOther", "") .add("FromName", "") .add("Password", "") .add("Username", "") .add("MessageHTML", "") .add("ToWebDatabase", "") .add("FromEmail", "") .add("MessagePlain", "") .build()) // Fetch request and return content .execute().returnContent(); // Print content System.out.println(content); } catch (IOException e) { System.out.println(e); } } }
Swift+Alamofire
class MyRequestController { func sendRequest() { // SendMassEmail (POST https://api.jangomail.com/api.asmx/SendMassEmail) // Create manager var manager = Manager.sharedInstance // Add Headers manager.session.configuration.HTTPAdditionalHeaders = [ "Content-Type":"application/x-www-form-urlencoded", ] // Form URL-Encoded Body let bodyParameters = [ "ToGroups":"", "ToGroupFilter":"", "Subject":"", "Options":"", "ToOther":"", "FromName":"", "Password":"", "Username":"", "MessageHTML":"", "ToWebDatabase":"", "FromEmail":"", "MessagePlain":"", ] let encoding = Alamofire.ParameterEncoding.URL // Fetch Request Alamofire.request(.POST, "https://api.jangomail.com/api.asmx/SendMassEmail", parameters: bodyParameters, encoding: encoding) .validate(statusCode: 200..<300) .responseJSON{(request, response, JSON, error) in if (error == nil) { println("HTTP Response Body: (JSON)") } else { println("HTTP HTTP Request failed: (error)") } } } } [tabby title="PHP"] "", "ToGroupFilter" => "", "Subject" => "", "Options" => "", "ToOther" => "", "FromName" => "", "Password" => "", "Username" => "", "MessageHTML" => "", "ToWebDatabase" => "", "FromEmail" => "", "MessagePlain" => "", ]; $body = http_build_query($body); // Set body curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); // Send the request & save response to $resp $resp = curl_exec($ch); if(!$resp) { die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch)); } else { echo "Response HTTP Status Code : " . curl_getinfo($ch, CURLINFO_HTTP_CODE); echo "nResponse HTTP Body : " . $resp; } // Close request to clear up some resources curl_close($ch);
Ruby
require 'net/http' require 'net/https' def send_request # SendMassEmail (POST ) begin uri = URI('https://api.jangomail.com/api.asmx/SendMassEmail') # Create client http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER data = { "ToGroups" => "", "ToGroupFilter" => "", "Subject" => "", "Options" => "", "ToOther" => "", "FromName" => "", "Password" => "", "Username" => "", "MessageHTML" => "", "ToWebDatabase" => "", "FromEmail" => "", "MessagePlain" => "", } body = URI.encode_www_form(data) # Create Request req = Net::HTTP::Post.new(uri) # Add headers req.add_field "Content-Type", "application/x-www-form-urlencoded" # Set header and body req.body = body # Fetch Request res = http.request(req) puts "Response HTTP Status Code: #{res.code}" puts "Response HTTP Response Body: #{res.body}" rescue StandardError => e puts "HTTP Request failed (#{e.message})" end end
How to use the API
The JangoMail API is a remotely accessible web service that you can interact with through several methods, all of which are available across the internet. This allows you to get data into and out of your JangoMail account programmatically without visiting the JangoMail website. It is helpful to know how to use a web service based API in order to use the JangoMail API. A tutorial on our API can be found here. RESTful API documentation can be found here.
Benefits of Sending Emails through JangoMail’s API
Our API can be used to do virtually everything that can be done in our User Interface. Integrate our API with your marketing platforms and applications to send email seamlessly. Save time and money by automating your email marketing messages. Emails sent through the JangoMail API benefit from JangoMail’s deliverability and compliance features. Reporting statistics can be accessed through our UI or pulled through the UI or pulled back through the API which makes the data easy to use in your own reporting.