Integrate in Minutes
Not a developer? Check out our marketing email features and our best practice resources.
cat < post_body.txt
{
"username":"smtpprov-u00100205'",
"password":"YOUR_PASSWORD",
"message":{
"html":"html content goes here",
"text":"text content goes here",
"subject":"this is the subject",
"to":[
{
"email":"recipient@example.com",
"name":"John Doe"
}
],
"from_email":"from@example.com",
"from_name":"Your Company",
"mailclass":"trans",
"headers":{
"X-foo":"bar"
}
}
}
EOT
curl -X POST -H "Content-Type: application/json" --data-binary @post_body.txt http://spsrvr.com/api/v1/send.json
<?php
$smtp_username='smtpprov-u00100205';
$smtp_password='YOUR_PASSWORD';
$json='{
"username":"'.$smtp_username.'",
"password":"'.$smtp_password.'",
"message":{
"html":"html content goes here",
"text":"text content goes here",
"subject":"this is the subject",
"to":[
{
"email":"user1@abc.com",
"name":"user1"
}
],
"from_email":"user2@example.com",
"from_name":"user2"
}
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://spsrvr.com/api/v1/send.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
));
$output = curl_exec($ch);
print_r($output) ;
F
HttpClient hc = new DefaultHttpClient();
String message;
HttpPost p = new HttpPost("http://spsrvr.com/api/v1/send.json");
String str1="{ "username":"UserName"," +
" "password":"Password"," +
" "message":{" +
" "html":"the body here"," +
" "text":"test"," +
" "subject":"please check this paryt"," +
" "to":[" +
" {" +
" "email":"abc@cdf.com"," +
" "name":"abc"" +
" }" +
" ]," +
" "from_email":"cdf@efg.com"," +
" "from_name":"blueberry"" +
" }" +
"}";
try {
JSONObject object = new JSONObject(str1);
message = object.toString();
Log.v("message Test here",message);
p.setEntity(new StringEntity(message, "UTF8"));
p.setHeader("Content-type", "application/json");
HttpResponse resp = hc.execute(p);
if (resp != null) {
Log.v("message Test here","mail send "+resp);
}
} catch (JSONException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
let request = NSMutableURLRequest(URL: NSURL(string: "https://spsrvr.com/api/v1/send.json")!, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData, timeoutInterval: 5)
var response: NSURLResponse?
let username = "ApiUserName"
let pass = "ApiPassWord"
let htmlBody = "html content"
let text = "text"
let subject = "subject text"
let toEmail = "reciver email Id"
let toName = "reciver person name"
let from_email = "sender email Id"
let from_name = "sender name"
// create some JSON data and configure the request
let jsonString = "{ "username":""+username+"", "password":""+pass+"", "message":{ "html":""+htmlBody+"", "text":""+text+"","subject":""+subject+"", "to":[{ "email":""+toEmail+"", "name":""+toName+"" }],"from_email":""+from_email+"", "from_name":""+from_name+"" }}";
request.HTTPBody = jsonString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
request.HTTPMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
// send the request
do {
let data = try NSURLConnection.sendSynchronousRequest(request, returningResponse: &response)
if let httpResponse = response as? NSHTTPURLResponse {
print("HTTP response: (httpResponse.statusCode)")
} else {
print("No HTTP response")
}
} catch (let e) {
print(e)
}
NSString *urlString = [NSString stringWithFormat:@"%s", "https://spsrvr.com/api/v1/send.json"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSError *error;
NSDictionary *dic3=@{@"email":@"Receiver EmailId",
@"name":@"Receiver Name"};
NSDictionary *dict2 = @{@"html":@"html content goes here",
@"text":@"text content goes here",
@"subject":@"this is the subject",
@"to" : @[dic3],
@"from_email":@"Sender Email id",
@"from_name":@"Sender name",
@"mailclass":@"mailClassname"
};
NSDictionary *dict = @{@"username" : @"API UserName",
@"password" : @"API Password",
@"message" :dict2
}
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
NSString *jsonString;
if (! jsonData) {
NSLog(@"Got an error: %@", error);
} else {
jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSLog(@"jsonString: %@", jsonString);
NSData *requestData = [NSData dataWithBytes:[jsonString UTF8String] length:[jsonString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json; charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
NSURLResponse * response = nil;
NSError * NSURLRequestError = nil;
NSData * responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&NSURLRequestError];
NSLog(@"%@",response);
}