cURL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
curl -X "POST" "https://api.jangomail.com/api.asmx/SendMassEmail" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "ToGroups=<Your Email List>" --data-urlencode "ToGroupFilter=<Your List Filter>" --data-urlencode "Subject=<Your Subject Line>" --data-urlencode "Options=<Additional Sending Options>" --data-urlencode "ToOther=<Your Additional Addresses>" --data-urlencode "FromName=<Your From Name>" --data-urlencode "Password=<Your Password>" --data-urlencode "Username=<Your Username>" --data-urlencode "MessageHTML=<Your HTML Message>" --data-urlencode "ToWebDatabase=<Your Web Database>" --data-urlencode "FromEmail=<Your From Address>" --data-urlencode "MessagePlain=<Your Plaintext Message>" |
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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": "<Your Email List>", "ToGroupFilter": "<Your List Filter>", "Subject": "<Your Subject Line>", "Options": "<Additional Sending Options>", "ToOther": "<Your Additional Addresses>", "FromName": "<Your From Name>", "Password": "<Your Password>", "Username": "<Your Username>", "MessageHTML": "<Your HTML Message>", "ToWebDatabase": "<Your Web Database>", "FromEmail": "<Your From Address>", "MessagePlain": "<Your Plaintext Message>", }, ) 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
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)") } } } } |
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<?php // Get cURL resource $ch = curl_init(); // Set url curl_setopt($ch, CURLOPT_URL, 'https://api.jangomail.com/api.asmx/SendMassEmail'); // Set method curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); // Set options curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Set headers curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/x-www-form-urlencoded", ] ); // Create body $body = [ "ToGroups" => "", "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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
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 |