JangoMail FAQs

Java and our API

The call to our API using Java is just like calling any other URL where you pass in parameters. The example below also displays the response from your call to the API (success message and the transactional message ID).

The method used for this example is SendTransactionEmail. Our methods are shown at api.jangomail.com.

//Send transactional email example
//Compile JangoJavaAPI.java to get JangoJavaAPI.class

//Execution: java JangoJavaAPI

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

public class JangoJavaAPI {

  public static void main(String[] args) throws Exception {
    URL url = new URL("http://api.jangomail.com/api.asmx/SendTransactionalEmail");
    URLConnection conn = url.openConnection();
    conn.setDoOutput(true);
    OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());

writer.write("Username=JangoUN&Password=JangoPW&FromEmail=you@somewhere.com&FromName=YourName&ToEmailAddress=someone@somewhere.com&Subject=JangoJavaAPI&MessagePlain=hello&MessageHTML=<p>hello</p>&Options=OpenTrack=true");

    writer.flush();
    String line;
    BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    while ((line = reader.readLine()) != null) {
      System.out.println(line);
    }
    writer.close();
    reader.close();

  }
}