Sends an email with attachments.
This API deprecates the older httpSendMail() API.
You can provide an HTML content for an email along with one or multiple attachments, and the API sends the email and attachment(s) to the email address(es) provided.
HTML with AMP content should be provided correctly in the “amp” field, and should be accompanied by an HTML not containing any AMP content in the “body” field.
There should be at least one recipient email address provided for any one of the following parameters: to / cc / bcc *. Emails to each of these recipients will be sent separately. The email addresses provided will get added as subscribers to a new List “API_EMAILS” in your Juvlon Account.
You can send out attachments if you have attachment-sending enabled in your Juvlon account. The following types of files are allowed as attachments:
- .ics
- .doc, .docx
- .csv, .xls, .xlsx
- .jpg, .png, .gif
This API needs to be called using an HTTP Post method with data in JSON format as shown below.
URL: https://api2.juvlon.com/v5/sendEmail
JSON Parameters
'{"apiKey":"$apiKey", "from":"$from", "fromName":"$fromName", "replyTo":"$replyTo", "to":"$to", "cc":"$cc", "bcc":"$bcc", "subject":"$subject", "body":"urlencode($body)", "amp":"urlencode($amp)", "trackClicks":"$trackClicks", "sendWithoutAttachment":"$sendWithoutAttachment", "customField":"$customField", "attachments": [{ "attachmentContent":"$attachment1Content", "attachmentFileName":"$attachment1FileName" },{ "attachmentContent":"$attachment2Content", "attachmentFileName":"$attachment2FileName" }] }';
Arguments
Name | Type | Description | Default |
apiKey | String | Mandatory. The apiKey that gives you access to our HTTP APIs. The apiKey authenticates you and helps us to identify your Juvlon account. | |
from | String | Mandatory. The email address to be used as the sender of the email. There should already be an active sender with the same email address in your Juvlon account. | |
fromName | String | The name to be used for the sender of the email. | |
replyTo | String | The email address to which replies should be sent. | |
to | String | Comma separated email addresses to whom the email has to be sent. * | |
cc | String | Comma separated email addresses to whom the email has to be carbon copied. * | |
bcc | String | Comma separated email addresses to whom the email has to be blind carbon copied. * | |
subject | String | Mandatory. The subject of the email to be sent out. The subject cannot have any personalization. | |
body | String | Mandatory. The urlencoded HTML content of the email to be sent out. All the images and links will be checked for blacklisted domains, and the email will get sent out only if they are all clean. | |
amp | String | The urlencoded AMP HTML content of the email to be sent out. All the images and links will be checked for blacklisted domains, and the email will get sent out only if they are all clean. | |
campaignName | String | The campaign for this Email. All analytics (Opens / Clicks / Bounces / Opt-outs etc.) will be saved against this campaign. Creates a new campaign with this name if it does not already exist. When you login to Juvlon, you will find a campaign and an email with this name (as provided in the API call). You can then click on the analytics icon of the email to view all analytics. | |
trackClicks | Int | Set flag 1 to enable clicks tracking (default), 0 for no clicks tracking | |
sendWithoutAttachment | Int | Used in case any/all attachment(s) provided is not supported (see the list of supported attachment types in the API description above). Set to: 1 to send the email anyway without the not-supported attachments (default), 0 to not send the email at all. | |
customField | String | Customized text for your internal tracking. | |
attachments | Structure | A list / array of files to be sent as attachments in an email. The list should be provided within square braces [ ], and each attachment should be provided within curly braces { } Note that attachments are allowed only if you have attachment-sending enabled for your Juvlon account. | |
attachmentFileName | String | Mandatory. The filename to be set for the attachment. | |
attachmentContent | String | Mandatory. Base64-encoded content of the file to be attached to the email. |
Return values
Name | Type | Description |
code | String | The Success or Error response code as returned by the API. Please refer to the section “Possible-Response-Codes” for more details. |
status | String | Description of the error code returned. |
transactionId | String | A number generated by the API to uniquely identify the current call. Also known as the API_Call_ID. |
Usage / Example(s)
PHP Example Code for Integration
$url = 'https://api2.juvlon.com/v5/sendEmail'; $data = '{"apiKey":"KEY", “from":"from@abc.com", "fromName":"support@juvlon.com", "replyTo":"reply-to@juvlon.com", "to":"recipient@juvlon.com", "cc":"cc-recipient@juvlon.com", "bcc":"bcc-recipient@juvlon.com", "subject":"Hello", "body":"This is the body of the Email", "trackClicks":"1", "sendWithoutAttachment":"1", "customField":"This is a custom text for tracking", "attachments": [{ "attachmentContent":"UEsDBBQACAgIACwl...E4NAAAAAA==", "attachmentFileName":"Document.docx" },{ "attachmentContent":"UEsDBBQACAgIACwl...E4NAAAAAA==", "attachmentFileName":"Image.jpg" }] }'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $res1 = curl_exec($ch); curl_close($ch);
Success-Response
HTTP/1.1 { "code":"200", "status":"Success", "transactionId":327 }
Error-Response
HTTP/1.1 { "code":"403", "status":"Error" }
Possible-Response-Codes
200 Success: API Request Accepted 401 Error:Invalid Method 402 Error: Unauthorized/Empty Key 403 Error: Unauthorized/Invalid Key 404 Error: Account Sending Blocked 405 Error: Your Juvlon account is expired 448 Your Juvlon account is Deactivated 406 Error: Email Subject not provided 407 Error: Invalid Email Address for reply-to 408 Error: Body content not provided 409 Error: Sender Email not Provided 410 Error: Invalid Email Address for Sender 411 Error: No recipient email address provided 412 Error: Invalid recipient email address 413 Error: Blacklisted domain in the HTML 414 Error: Sender Domain Blacklisted 415 Error: Reply-to domain blacklisted 416 Error: Recipient Email Domain blacklisted 417 Bounced 418 Delivered 420 Error: Sender email does not exist in your Juvlon account 421 Error: Sender not activated 443 Error: INACTIVE Subscriber 444 Low Subscriber credit 445 Low Email credit 451 Opened 452 Clicked 465 Error: attachment type not allowed 466 Error: attachment not enabled in your account 467 Error: Exceeded the maximum attachment size for your account 468 Error: attachment Name/Content not Provided 475 Error: Json is not valid 476 Error: Subject not valid 477 Error: From Name not valid