Description
This API allows applications to send emails through a remote SMTP server. It handles authentication, email composition, and delivery, supporting plain text and HTML emails, attachments, and secure connections via TLS/SSL..
It supports the following SMTP providers:
1.turboSMTP
2.SMTP2GO
3.SendGrid
4.Other SMTP
parameters
1.turbosmtp
2.smtp2go
3.sendgrid
3.Other_smtp
Sample Code
curl --insecure -u "root:PASSWORD" "https://SERVER_IP:2005/index.php?api=json&act=remote_smtp_servers&provider=PROVIDER&smtp_host=SMTP_HOST&smtp_port=SMTP_PORT&uname=USERNAME&passwd=PASSWORD&apikey=API_KEY&setservice=Save"
<?php
$user = 'root';
$pass = 'PASSWORD';
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@SERVER_IP/HOSTNAME:2005/index.php?api=json&act=remote_smtp_servers';
/* providers = ['none', 'turbosmtp','smtp2go','sendgrid', 'custom_smtp']; */
// For other_smtp
$post = array('provider' => 'other_smtp',
'smtp_host' => 'REMOTE_IP',
'smtp_port' => '587', // 487
'uname' => 'EMAILID',
'passwd' => 'PASSWORD',
'setservice' => 'Save',
);
// For turbosmtp
/* $post = array('provider' => 'turbosmtp',
'smtp_port' => '587',
'uname' => 'EMAILID',
'passwd' => 'PASSWORD',
'setservice' => 'Save',
); */
// For smtp2go
/* $post = array('provider' => 'smtp2go',
'apikey' => 'API_KEY'
'smtp_port' => '587',
'uname' => 'EMAILID',
'passwd' => 'PASSWORD',
'setservice' => 'Save',
); */
// For sendgrid
/* $post = array('provider' => 'smtp2go',
'apikey' => 'API_KEY'
'smtp_port' => '587', //465
'setservice' => 'Save',
); */
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method.
$res = json_decode($resp, true);
print_r($res);