Mailpress SMTP Mail Engine API Documentation
You have a killer email marketing campaign locked and loaded. Now, how to send it to the 2000 or 2 million email addresses on your contact list? For most marketers, an email service provider (ESP) is the answer to reliably and effectively delivering mass email without the hassle or costs of trying to do it yourself. ESPs often provide email marketing software that helps you manage and deliver your messages. However, using an email service doesn't mean you'll break the bank sending content to your subscribers. We offer comprehensive deliverability features and powerful marketing automation tools without breaking local laws.
Below are the endpoints for accessing On-Demand Mail Engine. Learn how to integrate the API into your application.
Authorization:
- privateId *Specify privateId for site
(e.g., "Bearer example^com-SomeIdString").
Query Parameters:
- type Specify type of SES
for Transactional OTP (e.g., type:"OTP").
for Promotional Bulk (e.g., type:"TMP").
for Informational personalized (e.g., type:"CXT").
Body Parameters:
- mailId Specify the array of mail address
(e.g., ["email@domain.com"]). - :data Specify the mail OTP|TMP|CXT string
for Transactional OTP (e.g., OTP:"000000").
for Promotional Bulk (e.g., TMP:"template-id-here").
for Informational personalized (e.g., CXT:"html-email").
Route Parameters:
- :region *Please check location table here
(e.g., "WEST_3|ARAB_1|EAST_3|NORD_6").
Response based on params:
{ "success": true, "info": "SES OTP Sent!" }
This endpoint provides the mail for sending bulk email.
import Foundation struct APIClient { static let baseURL = "https://mailpress.api.koirang.com/v1/:region" static let privateId = "<privateId>" static func fetchData() async throws -> [String: Any] { // API configuration let params = [ "region": "YOUR_REGION" // Replace with actual region value ] // Build URL var urlComponents = URLComponents(string: baseURL)! // Add path parameters let pathParams = ["region"] let pathItems = pathParams.map { params[$0]! } urlComponents.path += "/" + pathItems.joined(separator: "/") // Add query parameters let queryParams: [String: String] = {"mailId":"example@domain.com","OTP":"000000"} urlComponents.queryItems = queryParams.map { URLQueryItem(name: $0.key, value: $0.value) } guard let url = urlComponents.url else { throw URLError(.badURL) } // Create request var request = URLRequest(url: url) request.httpMethod = "GET" request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.setValue("Bearer \(privateId)", forHTTPHeaderField: "Authorization") // Add body for POST/PUT requests if ["POST", "PUT"].contains("GET") { let bodyData = {"type":"OTP"} request.httpBody = try JSONSerialization.data(withJSONObject: bodyData) } // Send request let (data, response) = try await URLSession.shared.data(for: request) guard let httpResponse = response as? HTTPURLResponse else { throw URLError(.badServerResponse) } guard httpResponse.statusCode < 400 else { throw URLError(.badServerResponse) } guard let result = try JSONSerialization.jsonObject(with: data) as? [String: Any] else { throw URLError(.cannotParseResponse) } return result } } // Example usage @main struct APIExample { static func main() async { do { let result = try await APIClient.fetchData() let prettyJSON = try JSONSerialization.data(withJSONObject: result, options: .prettyPrinted) if let jsonString = String(data: prettyJSON, encoding: .utf8) { print(jsonString) } } catch { print("Error: \(error)") } } }