This module acts as an Email Service Management that can be used by App to configure email ids and send mails to one or multiple recipients.
In order to use various functions available in a specific API, a developer has to create an instance of ServiceAPI by passing the apiKey and secretKey which will be created after the app creation from AppHQ dashboard.
Required Parameters
apiKey - The Application key given when the application was created.
secretKey - The secret key corresponding to the application key given when the application was created.
ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI *api = [[ServiceAPI alloc]init]; api.apiKey = @"<API_KEY>"; api.secretKey = @"<SECRET_KEY>";ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");Not AvailableServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");$api = new ServiceAPI("API_KEY","SECRET_KEY");Coming Soonapi = App42::ServiceAPI.new("<API_KEY>","<SECRET_KEY>")Coming SoonComing Soon
After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of EmailService, buildEmailService() method needs to be called.
EmailService emailService = api.buildEmailService();EmailService emailService = api.BuildEmailService();EmailService *emailService = [api buildEmailService];EmailService emailService = api.buildEmailService();EmailService emailService = api.buildEmailService();EmailService emailService = api.BuildEmailService();Not AvailableEmailService emailService = api.BuildEmailService();$emailService = $api->buildEmailService();Coming Soonemail_service = api.build_email_service()Coming SoonComing Soon
import com.shephertz.app42.paas.sdk.android.ServiceAPI; import com.shephertz.app42.paas.sdk.android.App42Response; import com.shephertz.app42.paas.sdk.android.App42Exception; import com.shephertz.app42.paas.sdk.android.App42BadParameterException; import com.shephertz.app42.paas.sdk.android.App42NotFoundException; import com.shephertz.app42.paas.sdk.android.email.Email; import com.shephertz.app42.paas.sdk.android.email.EmailMIME; import com.shephertz.app42.paas.sdk.android.email.EmailService;using com.shephertz.app42.paas.sdk.windows; using com.shephertz.app42.paas.sdk.windows.email;#import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"import com.shephertz.app42.paas.sdk.jme.ServiceAPI; import com.shephertz.app42.paas.sdk.jme.App42Response; import com.shephertz.app42.paas.sdk.jme.App42Exception; import com.shephertz.app42.paas.sdk.jme.App42BadParameterException; import com.shephertz.app42.paas.sdk.jme.App42NotFoundException; import com.shephertz.app42.paas.sdk.jme.email.Email; import com.shephertz.app42.paas.sdk.jme.email.EmailMIME; import com.shephertz.app42.paas.sdk.jme.email.EmailService;import com.shephertz.app42.paas.sdk.java.ServiceAPI; import com.shephertz.app42.paas.sdk.java.App42Response; import com.shephertz.app42.paas.sdk.java.App42Exception; import com.shephertz.app42.paas.sdk.java.App42BadParameterException; import com.shephertz.app42.paas.sdk.java.App42NotFoundException; import com.shephertz.app42.paas.sdk.java.email.Email; import com.shephertz.app42.paas.sdk.java.email.EmailMIME; import com.shephertz.app42.paas.sdk.java.email.EmailService;using com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.email;Not Availableusing com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.email;use com\shephertz\app42\paas\sdk\php\App42Response; use com\shephertz\app42\paas\sdk\php\App42Exception; use com\shephertz\app42\paas\sdk\php\App42BadParameterException; use com\shephertz\app42\paas\sdk\php\App42NotFoundException; use com\shephertz\app42\paas\sdk\php\email\EmailService; use com\shephertz\app42\paas\sdk\php\ServiceAPI; include_once '../EmailService.php'; include_once '../ServiceAPI.php'; include_once '../App42Response.php'; include_once '../App42Exception.php'; include_once '../App42BadParameterException.php'; include_once '../App42NotFoundException.php';Coming Soonrequire 'App42_Ruby_API'Coming SoonComing Soon
Creates Email Configuration using which in future the App developer can send mail.
Required Parameters
emailHost - Email Host to be used for sending mail.
emailPort - Email Port to be used for sending mail.
emailId - Email id to be used for sending mail
password - Email Password to be used for sending mail
isSSL - Should be send using SSL or not.
String emailHost = "smtp.gmail.com"; int emailPort = 465; String emailId = "nick@shephertz.com"; String password = "********"; boolean isSSL = true; Email email = emailService.createMailConfiguration(emailHost,emailPort,emailId,password,isSSL); System.out.println("emailId is " + email.getConfigList().get(0).getEmailId()); System.out.println("Host is " + email.getConfigList().get(0).getHost()); String jsonResponse = email.toString();public class Callback : App42Callback { String emailHost = "smtp.gmail.com"; int emailPort = 465; String emailId = "nick@shephertz.com"; String password = "********"; boolean isSSL = true; emailService.CreateMailConfiguration(emailHost,emailPort,emailId,password,isSSL,this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Email email = (Email) response; Console.WriteLine("emailId is " + email.GetConfigList()[0].GetEmailId()); Console.WriteLine("Host is " + email.GetConfigList()[0].GetHost()); String jsonResponse = email.ToString(); } }NSString *emailHost = @"smtp.gmail.com"; int *emailPort = 465; NSString *emailId = @"nick@shephertz.co.in"; NSString *password = @"********"; BOOL isSSL = true; Email *email = [emailService createEmailConfiguration:emailHost emailPort:emailPort emailId:emailId emailPassword:password isSSL:isSSL]; NSLog(@"emailId is %@" , [(Configuration *)[email.configurationArray objectAtIndex:0] emailId); NSLog(@"Host is %@" , [(Configuration *)[email.configurationArray objectAtIndex:0] host); NSString jsonResponse = [email toString];String emailHost = "smtp.gmail.com"; int emailPort = 465; String emailId = "nick@shephertz.co.in"; String password = "********"; boolean isSSL = true; Email email = emailService.createMailConfiguration(emailHost,emailPort,emailId,password,isSSL); System.out.println("emailId is " + ((Email.Configuration)email.getConfigList().elementAt(0)).getEmailId()); System.out.println("Host is " + ((Email.Configuration)email.getConfigList().elementAt(0)).getHost()); String jsonResponse = email.toString();String emailHost = "smtp.gmail.com"; int emailPort = 465; String emailId = "nick@shephertz.com"; String password = "********"; boolean isSSL = true; Email email = emailService.createMailConfiguration(emailHost,emailPort,emailId,password,isSSL); System.out.println("emailId is " + email.getConfigList().get(0).getEmailId()); System.out.println("Host is " + email.getConfigList().get(0).getHost()); String jsonResponse = email.toString();`String emailHost = "smtp.gmail.com"; int emailPort = 465; String emailId = "nick@shephertz.com"; String password = "********"; boolean isSSL = true; emailService.CreateMailConfiguration(emailHost,emailPort,emailId,password,isSSL, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }Not AvailableString emailHost = "smtp.gmail.com"; int emailPort = 465; String emailId = "nick@shephertz.com"; String password = "********"; boolean isSSL = true; Email email = emailService.CreateMailConfiguration(emailHost,emailPort,emailId,password,isSSL); Console.WriteLine("emailId is " + email.GetConfigList()[0].GetEmailId()); Console.WriteLine("Host is " + email.GetConfigList()[0].GetHost()); String jsonResponse = email.ToString();$emailHost = "smtp.gmail.com"; $emailPort = 465; $emailId = "nick@shephertz.com"; $password = "********"; $isSSL = true; $email = $emailService->createMailConfiguration($userName, $pwd, $emailId); print_r("emailId is " . $email->getConfigList()[0]->getEmailId()); print_r("Host is " . $email->getConfigList()[0]->getHost()); $jsonResponse = $email->toString();Coming Soonemail_host = "smtp.gmail.com"; email_port = 465; mail_id = "nick@gmail.com"; email_password = "********"; isSSL = true; email = email_service.create_mail_configuration(emailHost,emailPort,mailId,emailPassword,isSSL); config_list = Array.new(); config_list = email.config_list(); for config in config_list do puts "emailId is #{config.email_id}"; puts "host is #{config.host}"; puts "port is #{config.port}"; end json_response = email.to_s();Coming SoonComing Soon
Gets all Email Configurations for the app.
Email email = emailService.getEmailConfigurations(); System.out.println("emailId is " + email.getConfigList().get(0).getEmailId()); System.out.println("Host is " + email.getConfigList().get(0).getHost()); String jsonResponse = email.toString();public class Callback : App42Callback { emailService.GetEmailConfigurations(this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Email email = (Email) response; Console.WriteLine("emailId is " + email.GetConfigList()[0].GetEmailId()); Console.WriteLine("Host is " + email.GetConfigList()[0].GetHost()); String jsonResponse = email.ToString(); } }Email *email = [emailService getEmailConfigurations] NSLog(@"emailId is %@" , [(Configuration *)[email.configurationArray objectAtIndex:0] emailId); NSLog(@"Host is %@" , [(Configuration *)[email.configurationArray objectAtIndex:0] host); NSString jsonResponse = [email toString];Email email = emailService.getEmailConfigurations(); System.out.println("emailId is " + ((Email.Configuration)email.getConfigList().elementAt(0)).getEmailId()); System.out.println("Host is " + ((Email.Configuration)email.getConfigList().elementAt(0)).getHost()); String jsonResponse = email.toString();Email email = emailService.getEmailConfigurations(); System.out.println("emailId is " + email.getConfigList().get(0).getEmailId()); System.out.println("Host is " + email.getConfigList().get(0).getHost()); String jsonResponse = email.toString();`emailService.getEmailConfigurations(new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }Not AvailableEmail email = emailService.getEmailConfigurations(); Console.WriteLine("emailId is " + email.GetConfigList()[0].GetEmailId()); Console.WriteLine("Host is " + email.GetConfigList()[0].GetHost()); String jsonResponse = email.ToString();$email = $emailService->getEmailConfigurations(); print_r("emailId is " . $email->getConfigList()[0]->getEmailId()); print_r("Host is " . $email->getConfigList()[0]->getHost()); $jsonResponse = $email->toString();Coming Soonemail = email_service.get_email_configurations(); config_list = Array.new(); config_list = email.config_list(); for config in config_list do puts "emailId is #{config.email_id}"; puts "host is #{config.host}"; puts "port is #{config.port}"; end json_response = email.to_s();Coming SoonComing Soon
Creates Email Configuration using which in future the App developer can send mail.
Required Parameters
senderEmailId - The Email Id using which the mail(s) has to be sent.
sendTo - The email ids to which the email has to be sent. Email can be sent to multiple email ids. Multiple email ids can be passed using comma as the seperator e.g. support@shephertz.com, info@shephertz.com.
sendSubject - Subject of the Email which to be sent.
sendMsg - Email body which has to be sent.
emailMime - MIME Type to be used for sending mail. EmailMime available options are PLAIN_TEXT_MIME_TYPE or HTML_TEXT_MIME_TYPE.
String sendTo = "nick@shephertz.co.in"; String sendSubject = "Feedback"; String sendMsg = "Your message"; String senderEmailId = "john@gmail.com"; Email email = emailService.sendMail(sendTo, sendSubject, sendMsg, senderEmailId,EmailMIME.PLAIN_TEXT_MIME_TYPE); System.out.println("emailId is " + email.getFrom()); System.out.println("subject is " + email.getSubject()); String jsonResponse = email.toString();public class Callback : App42Callback { String sendTo = "nick@shephertz.co.in"; String sendSubject = "Feedback"; String sendMsg = "Your message"; String senderEmailId = "john@gmail.com"; emailService.SendMail(sendTo, sendSubject, sendMsg, senderEmailId, "PLAIN_TEXT_MIME_TYPE",this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Email email = (Email) response; Console.WriteLine("emailId is " + email.GetFrom()); Console.WriteLine("subject is " + email.GetSubject()); String jsonResponse = email.ToString(); } }NSString NSString *sendTo = @"nick@shephertz.co.in"; NSString *sendSubject = @"Feedback"; NSString *sendMsg = @"Your message"; NSString *senderEmailId = @"john@gmail.com"; Email *email = [emailService sendMail:sendTo subject:sendSubject Message:sendMsg fromEmail:senderEmailId emailMIME:@"PLAIN_TEXT_MIME_TYPE"]; NSLog(@"from is %@" , email.from); NSLog(@"to is %@" , email.to); NSString jsonResponse = [email toString];String sendTo = "nick@shephertz.co.in"; String sendSubject = "Feedback"; String sendMsg = "Your message"; String senderEmailId = "john@gmail.com"; Email email = emailService.sendMail(sendTo, sendSubject, sendMsg, senderEmailId, EmailMIME.PLAIN_TEXT_MIME_TYPE); System.out.println("emailId is " + email.getFrom()); System.out.println("subject is " + email.getSubject()); String jsonResponse = email.toString();String sendTo = "nick@shephertz.co.in"; String sendSubject = "Feedback"; String sendMsg = "Your message"; String senderEmailId = "john@gmail.com"; Email email = emailService.sendMail(sendTo, sendSubject, sendMsg, senderEmailId,EmailMIME.PLAIN_TEXT_MIME_TYPE); System.out.println("emailId is " + email.getFrom()); System.out.println("subject is " + email.getSubject()); String jsonResponse = email.toString();`String sendTo = "nick@shephertz.co.in"; String sendSubject = "Feedback"; String sendMsg = "Your message"; String senderEmailId = "john@gmail.com"; emailService.SendMail(sendTo, sendSubject, sendMsg, senderEmailId, "PLAIN_TEXT_MIME_TYPE",new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }Not AvailableString sendTo = "nick@shephertz.co.in"; String sendSubject = "Feedback"; String sendMsg = "Your message"; String senderEmailId = "john@gmail.com"; Email email = emailService.SendMail(sendTo, sendSubject, sendMsg, senderEmailId, "PLAIN_TEXT_MIME_TYPE"); Console.WriteLine("emailId is " + email.GetFrom()); Console.WriteLine("Host is " + email.GetSubject()); String jsonResponse = email.ToString();$sendTo = "nick@shephertz.co.in"; $sendSubject = "Feedback"; $sendMsg = "Your message"; $senderEmailId = "john@gmail.com"; $email = $emailService->sendMail($sendTo, $sendSubject, $sendMsg, $senderEmailId, $"PLAIN_TEXT_MIME_TYPE"); Print_r("from is " . $email->getFrom()); Print_r("to is " . $email->getTo()); $jsonResponse = $email->toString();Coming Soonsend_to = "bob@gmail.com"; send_subject = "Here we are sending an Email"; send_msg = "Body of message"; from_email_id = "jack@gmail.com"; email_mime = App42::Email::EmailMIME.new(); email_mime_type = emailMime.enum("PLAIN_TEXT_MIME_TYPE"); email = email_service.send_mail(send_to, send_subject, send_msg, from_email_id, email_mime_type); puts "from #{email.from}"; puts "to #{email.to}"; puts "subject is #{email.subject}"; puts "body #{email.body}"; json_response = email.to_s();Coming SoonComing Soon
Removes email configuration for the given email id. Note: In future the developer wont be able to send mails through this id
Required Parameters
emailId - The email id for which the configuration has to be removed.
String emailId = "nick@shephertz.co.in"; App42Response response = emailService.removeEmailConfiguration(emailId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();public class Callback : App42Callback { String emailId = "nick@shephertz.co.in"; emailService.RemoveEmailConfiguration(emailId, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { App42Response success = (App42Response) response; String jsonResponse = success.ToString(); } }NSString *emailId = @"nick@shephertz.co.in"; App42Response *response = [emailService removeEmailConfiguration:emailId]; NSString *success = response.isResponseSuccess; NSString *jsonResponse = [response toString];String emailId = "nick@shephertz.co.in"; App42Response response = emailService.removeEmailConfiguration(emailId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String emailId = "nick@shephertz.co.in"; App42Response response = emailService.removeEmailConfiguration(emailId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();`String emailId = "nick@shephertz.co.in"; emailService.RemoveEmailConfiguration(emailId,new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }Not AvailableString emailId = "nick@shephertz.co.in"; App42Response response = emailService.RemoveEmailConfiguration(emailId); Boolean success = response.IsResponseSuccess(); String jsonResponse = response.ToString();$emailId = "nick@shephertz.co.in"; $response = $emailService->removeEmailConfiguration($emailId); $success = $respons->isResponseSuccess(); $jsonResponse = $respons->toString();Coming Soonemail_id = "nick@gmail.com"; response = email_service.remove_email_configuration(email_id); success = response.is_response_success(); json_response = email.to_s();Coming SoonComing Soon
The functions available under Email API can throw some exceptions in abnormal conditions. Example of the same has been given below. E.g. If App developer is removing the email configuration that does not exist, the function will throw the App42Exception (as shown below) with message as “Not Found” and the appErrorCode as “2303” and the details as “Email with the id ‘nick@shephertz.co.in’ does not exist”.
String emailId = "nick@shephertz.co.in"; try { Email email = emailService.removeEmailConfiguration(emailId); } catch(App42Exception exception) { int appErrorCode = exception.getAppErrorCode(); int httpErrorCode = exception.getHttpErrorCode(); if(appErrorCode == 2303) { // Handle here for Not Found (Email with the id 'nick@shephertz.co.in' does not exist.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.getMessage(); }public class Callback : App42Callback { String emailId = "nick@shephertz.co.in"; emailService.RemoveEmailConfiguration(emailId,this); void App42Callback.OnException(App42Exception exception) { int appErrorCode = exception.GetAppErrorCode(); int httpErrorCode = exception.GetHttpErrorCode(); if(appErrorCode == 2303) { // Handle here for Not Found (Email with the id 'nick@shephertz.co.in' does not exist.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.GetMessage(); } void App42Callback.OnSuccess(Object response) { Email email = (Email) response; String jsonResponse = email.ToString(); } }String *emailId = @"nick@shephertz.co.in"; try { Email *email = [emailService removeEmailConfiguration:emailId]; } catch(App42Exception *exception) { int appErrorCode = exception.appErrorCode; int httpErrorCode = exception.httpErrorCode; if(appErrorCode == 2303) { // Handle here for Not Found (Email with the id '@emailId' does not exist.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String *jsonText = exception.reason; }String emailId = "nick@shephertz.co.in"; try { Email email = emailService.removeEmailConfiguration(emailId); } catch(App42Exception exception) { int appErrorCode = exception.getAppErrorCode(); int httpErrorCode = exception.getHttpErrorCode(); if(appErrorCode == 2303) { // Handle here for Not Found (Email with the id 'nick@shephertz.co.in' does not exist.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.getMessage(); }String emailId = "nick@shephertz.co.in"; try { Email email = emailService.removeEmailConfiguration(emailId); } catch(App42Exception exception) { int appErrorCode = exception.getAppErrorCode(); int httpErrorCode = exception.getHttpErrorCode(); if(appErrorCode == 2303) { // Handle here for Not Found (Email with the id 'nick@shephertz.co.in' does not exist.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.getMessage(); }`Coming SoonNot AvailableString emailId = "nick@shephertz.co.in"; try { Email email = emailService.RemoveEmailConfiguration(emailId); } catch(App42Exception exception) { int appErrorCode = exception.GetAppErrorCode(); int httpErrorCode = exception.GetHttpErrorCode(); if(appErrorCode == 2303) { // Handle here for Not Found (Email with the id 'nick@shephertz.co.in' does not exist.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.GetMessage(); }$emailId = "nick@shephertz.co.in"; try { $email = emailService->removeEmailConfiguration(emailId); } catch(App42Exception $exception) { $appErrorCode =$exception->getAppErrorCode(); $httpErrorCode = $exception->getHttpErrorCode(); if($appErrorCode == 2303) { // Handle here for Not Found (Email with the id 'nick@shephertz.co.in' does not exist.) } else if($appErrorCode == 1401) { // handle here for Client is not authorized } else if($appErrorCode == 1500) { // handle here for Internal Server Error } $jsonText = $exception->getMessage(); }Coming SoonComing SoonComing SoonComing Soon
Functions in Email API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again
2300 - NOT FOUND - Email parameters not found.
2301 - BAD REQUEST - The request parameters are invalid. Email id '@emailId' already exists.
2302 - NOT FOUND - Email configurations do not exist.
2303 - NOT FOUND - Email with the id '@emailId' does not exist.