C#
using System;
using System.IO;
using System.Net;
using System.Text;
public class Program
{
public static void Main()
{
// Create a request using a URL that can receive a post.
WebRequest request =WebRequest.Create("http://api.pepipost.com/api/web.send.rest");
// Set the Method property of the request to POST.
request.Method="POST";
// Create POST data and convert it to a byte array.
var postData ="api_key=YourApiKey";
postData +="&subject=TestMail";
postData +="&fromname=YourName";
postData +="&from=example@yourcompany.in";
postData +="&recipients=abc@yourcompany.in";
postData +="&content=The is the mail content to send";
byte[] byteArray =Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType="application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength= byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray,0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader =new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
}
}PHP :
<?php
$from ="example@yourcompany.in";
$fromname ="Name";
$to ="someone@yourcompany.in";//Recipients list (semicolon separated)
$api_key ="YourApiKey";
$subject ="Test Mail";
$content ="This is my Mail Content";
$data=array();
$data['subject']= rawurlencode($subject);
$data['fromname']= rawurlencode($fromname);
$data['api_key']= $api_key;
$data['from']= $from;
$data['content']= rawurlencode($content);
$data['recipients']= $to;
$apiresult = callApi(@$api_type,@$action,$data);
echo trim($apiresult);
function callApi($api_type='', $api_activity='', $api_input=''){
$data = array();
$result = http_post_form("https://api.pepipost.com/api/web.send.rest", $api_input);
return $result;
}
function http_post_form($url,$data,$timeout=20){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_RANGE,"1-2000000");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_REFERER,@$_SERVER['REQUEST_URI']);
$result = curl_exec($ch);
$result = curl_error($ch)? curl_error($ch): $result;
curl_close($ch);
return $result;
}
?>Perl :
use strict;
use warnings;
use LWP::UserAgent;
my $from ='example@pepipost.com';
my $fromname ="YourName";
my $to ='abc@pepipost.com';
my $api_key ="YourApiKey";
my $subject ="Test Mail";
my $content ="This is my Mail Content";
my $browser = LWP::UserAgent->new;
my $response = $browser->post("http://api.pepipost.com/api/web.send.rest",
[
'api_key'=> $api_key,
'fromname'=> $fromname,
'from'=> $from,
'content'=> $content,
'subject'=> $subject,
'recipients'=> $to
],
);
if($response->status_line =~/200/){
print"Successful";}else{
print"Error";
}Python :
#!/usr/bin/python
import requests
from_email ='example@pepipost.com'
fromname ='Your Name'
api_key ='Your Api Key'
subject ='Test Mail'
recipients ='abc@pepipost.com'
content ='This is my Mail Content'
pepipost= requests.post("http://api.pepipost.com/api/web.send.rest", data={'api_key': api_key,'subject': subject,'fromname': fromname,'from': from_email ,'recipients': recipients ,'content': content })
print(pepipost.status_code, pepipost.reason)JAVA :
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
publicclassJavasample{
publicstaticvoid main(String[] args){
String to ="example@pepipost.com";
String apikey ="YourApiKey";
Stringfrom="example@pepipost.com";
String fromname ="ABC";
String content ="This is Mail Content";
String subject ="Test Mail";
String myurl ="http://api.pepipost.com/api/web.send.rest";
try{
String postData ="api_key="+apikey;
postData +="&subject="+URLEncoder.encode(subject,"UTF-8");
postData +="&fromname="+URLEncoder.encode(fromname,"UTF-8");
postData +="&from="+from;
postData +="&recipients="+to;
postData +="&content="+URLEncoder.encode(content,"UTF-8");
String urlParameters = postData;
URL url =new URL(myurl);
HttpURLConnection connection;
connection =(HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length",""+Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language","en-US");
connection.setUseCaches (false);
connection.setDoInput(true);
connection.setDoOutput(true);
DataOutputStream wr =newDataOutputStream(connection.getOutputStream ());
wr.writeBytes (urlParameters);
wr.flush ();
wr.close ();
BufferedReaderin=newBufferedReader(newInputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response =newStringBuffer();
while((inputLine =in.readLine())!=null){
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
}
catch(Exception e){
e.printStackTrace();
}
}
}