Messages Calls
/messages/sendMail
Send a new transactional message through PowerEmail
Example Call
var PowerEmail= require('./PowerEmail.js');
var PowerEmail_client = new PowerEmail.PowerEmail('owner_id', 'token', 'PowerEmailTES_APP_DOMAIN');
var param = {
"smtp_user_name": "smtp12345",
"message": {
"html": "Example HTML content",
"text": "Example text content",
"subject": "example subject",
"from_email": "[email protected]",
"from_name": "Example Name",
"to": [{
"email": "[email protected]",
"name": "Recipient Name",
"type": "to",
}],
"headers": {
"Reply-To": "[email protected]",
"X-Unique-Id": "id",
},
"attachments": [{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl",
]},
"images": [{
"type": "image/png",
"name": "IMAGECID",
"content": "ZXhhbXBsZSBmaWxl",
}]
}
};
PowerEmail_client.messages.sendMail(param, function(result) {
console.log(result);
/*
{
"status" : "success",
"message" : "message have been Queued ... "
}
*/
}, function (e) {
// PowerEmailreturns the error as an object with name and message keys
console.log('A PowerEmailerror occurred: " + e.name + ' - ' + e.message);
});
Example Success Response
{
"status": "success",
"message": "Webhook Added"
}
Example Error Response
{
"status" => "error",
:code" => "-1",
:name" => "AuthenticationError",
"message" => Token MissMatch,
}
Parameters |
owner_id* string |
a valid PowerEmailUser Id |
token* string |
a valid token |
PowerEmailTES_APP_DOMAIN* string |
a valid PowerEmailTES APP DOMAIN |
smtp_user_name* string |
a valid smtp user name |
* compulsory field
** Either 'html' field Or 'text' field compulsory
Return Value: Success |
struct |
the results of sending mail
status string |
always success |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to List Tracking Domain
statusstring |
error |
messagestring |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. PowerEmailDevelopers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/messages/sendTemplate
Send a new transactional message using templates
Example Call
var PowerEmail= require('./PowerEmail.js');
var PowerEmail_client = new PowerEmail.PowerEmail('owner_id', 'token', 'PowerEmailTES_APP_DOMAIN');
var param = {
"smtp_user_name": "smtp12345",
"message": {
"template_id": "template_id",
"subject": "example subject",
"from_email": "[email protected]",
"from_name": "Example Name",
"to": [{
"email": "[email protected]",
"name": "Recipient Name",
"type": "to",
}],
"headers": {
"Reply-To": "[email protected]",
"X-Unique-Id": "id",
},
"dynamic_value": {"NAME" : "xyz","Email" : "[email protected]"},
"attachments": [{
"type": "text/plain",
"name": "myfile.txt",
"content": "ZXhhbXBsZSBmaWxl",
]},
"images": [{
"type": "image/png",
"name": "IMAGECID",
"content": "ZXhhbXBsZSBmaWxl",
}]
}
};
PowerEmail_client.messages.sendTemplate(param, function(result) {
console.log(result);
/*
{
"status" : "success",
"message" : "message have been Queued ... "
}
*/
}, function (e) {
// PowerEmailreturns the error as an object with name and message keys
console.log('A PowerEmailerror occurred: " + e.name + ' - ' + e.message);
});
Example Success Response
{
"status": "success",
"message": "Webhook Added"
}
Example Error Response
{
"status" => "error",
:code" => "-1",
:name" => "AuthenticationError",
"message" => Token MissMatch,
}
Parameters |
owner_id* string |
a valid PowerEmailUser Id |
token* string |
a valid token |
PowerEmailTES_APP_DOMAIN* string |
a valid PowerEmailTES APP DOMAIN |
smtp_user_name* string |
a valid smtp user name |
* compulsory field
Return Value: Success |
struct |
the results of sending mail
status string |
always success |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to List Tracking Domain
statusstring |
error |
messagestring |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. PowerEmailDevelopers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/messages/sendTemplateHTTPGet
Send a new transactional message using templates (HTTP GET method). This method doesn't require PowerEmailLibrary.
Example Call
var http= require('http');
var querystring= require('querystring');
var PowerEmailTES_APP_DOMAIN= 'PowerEmailTES_APP_DOMAIN';
var formData = {
'owner_id': 'owner_id',
'token': 'token',
'smtp_user_name': 'smtp123456',
'template_id': 'template_id',
'subject': 'hello',
'from_email': '[email protected]',
'to': '[email protected]',,
'dynamic_value[NAME]': 'xyz',
'dynamic_value[Email]': '[email protected]'
},
var qs = querystring.stringify(formData);
var url = "http://api." + PowerEmailTES_APP_DOMAIN + "/v1.0/messages/sendTemplateHTTPGet?" + qs;
http.get(url, function (res) {
const statusCode = res.statusCode;
if (statusCode !== 200) {
return console.log('Request Failed.');
}
res.setEncoding('utf8') {
var rawData = '';
res.on('data' function (chunk) {
rawData += chunk;
});
res.on('end' function () {
console.log(rawData);
});
}).on('error', function (e) {
console.log(e.toString());
});
Example Success Response
{
"status": "success",
"message": "message have been Queued ... "
}
Example Error Response
{
"status" => "error",
:code" => "-1",
:name" => "AuthenticationError",
"message" => Token MissMatch,
}
Parameters |
owner_id* string |
a valid PowerEmailUser Id |
token* string |
a valid token |
smtp_user_name* string |
a valid smtp user name |
template_id* string |
a valid previously created template id |
subject* string |
URL encoded subject |
from_email* string |
URL encoded from email |
to* string |
URL encoded to email |
dynamic_value struct |
optional dynamic values to replace dynamic fields on template. Dynamic fields are case sensitive. Example
NAME URL encoded string |
xyz URL encoded string |
Email URL encoded string |
info%40example.in URL encoded string |
|
* compulsory field
Return Value: Success |
struct |
the results of sending mail
status string |
queued |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to List Tracking Domain
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. PowerEmailDevelopers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |
/messages/getMessageInfo
get list of messages of specific x-unique-id
Note:- By default first 100 record will be fetch if don't pass second argument i.e. 'skip_page' or pass value of 'skip_page' is 0, if you want to fetch next 100 record then pass value of 'skip_page' is 1, and so on.
Example Call
var PowerEmail= require('./PowerEmail.js');
var PowerEmail_client = new PowerEmail.PowerEmail('owner_id', 'token', 'PowerEmailTES_APP_DOMAIN');
var param = {"x_unique_id":"test", "skip_page":0);
PowerEmail_client.settings.getWebhookInfo(param, function(result) {
console.log(result);
/*
{
"status": "success",
"message_data": [
{
"subject": "this is subject ..",
"sender": "[email protected]",
"email": "[email protected]",
"sendFrom": "0.0.0.0",
"mailSize": 1919,
"attchSize": 0,
"status": "delivered",
"time": 1458034022169,
"open": 1,
"openData": {
"ip": [
"0.0.0.0"
"0.0.0.0"
],
"ua": [
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)",
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)"
],
"time": [
1458039067963,
1458039067978
]
"clickData": {
"ip": [
"0.0.0.0"
"0.0.0.0"
],
"ua": [
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)",
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)"
],
"time": [
1458039068888,
1458039069999
]
},
"click": 1
}
]
}*/
)
)
)
*/
} catch (PowerEmail_Error $e) {
// PowerEmailerrors are thrown as exceptions
echo 'A PowerEmailerror occurred: %s - %s' % (e.__class__, e)
?>
Example Success Response
{
"status" : "success",
"message_data" : [
{
"subject" : "this is subject ..",
"sender" : "[email protected]",
"email" : "[email protected]",
"sendFrom" : "0.0.0.0",
"mailSize" : 1919,
"attchSize" : 0,
"status" : "delivered",
"time" : 1458034022169,
"open" : 1,
"openData" : {
"ip" : [
"0.0.0.0","0.0.0.0"
],
"ua" : [
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)",
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)"
],
"time" : [
1458039067963,1458039067978
]
},
"clickData" : {
"ip" : [
"0.0.0.0","0.0.0.0"
],
"ua" : [
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)",
"Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.in GoogleImageProxy)"
],
"time" : [
1458039068888,1458039069999
]
},
"click" : 1
}
]
}
Example Error Response
{
"status" => "error",
:code" => "-1",
:name" => "AuthenticationError",
"message" => Token MissMatch,
}
n
Parameters |
owner_id* string |
a valid PowerEmailUser Id |
token* string |
a valid token |
PowerEmailTES_APP_DOMAIN* string |
a valid PowerEmailTES APP DOMAIN |
x_unique_id* string |
a valid x-unique-id |
skip_page* integer |
a valid skip page |
* compulsory field
** Either 'html' field Or 'text' field compulsory
Return Value: Success |
struct |
the results of get mail info
status string |
always success |
message string |
human readable message |
|
|
Return Value: Error |
struct |
the error results when attempt to get mail info
status string |
error |
message string |
human readable message |
type string |
one of the error type as bellow table |
|
|
Error types |
ValidationError |
The parameters passed to the API call are invalid or not provided when required. |
GeneralError |
An unexpected errors occurred processing the request. PowerEmailDevelopers will be notified. |
AuthenticationError |
Provided owner_id and token was not matched. |