Anda dapat mengirim email transaksional menggunakan API kami dengan cURL. Pada setiap email yang Anda kirim, Anda dapat menggunakan tipe teks email, email HTML, email dengan lampiran, dan sebagainya.
Endpoint
Semua panggilan ke API perlu dimulai dengan URL dasar yang sesuai. Anda dapat memilih untuk menggunakan URL dasar sandbox kami atau URL dasar produksi selama implementasi.
Mailtarget production |
Opsi Pengiriman
Email dengan Body Text
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyText": "Example Email with Link\n\nDear [Name],\n\nWe are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.\n\nPlease click the following link to confirm your acceptance of the offer:\n\nAccept Offer (https://example.com/accept_offer)\n\nIf you have any questions or concerns, please do not hesitate to contact us at [email protected].\n\nBest regards,\n\n[Your Name]\n[Company Name]",
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"subject": "Example email with Body Text",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"metadata":{
"key1": "value1",
"key2": "value2",
}
}'HTML email
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyHtml": "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>Example Email with Link</title><style>body{font-family:Arial,sans-serif;background-color:#f5f5f5}h1{color:#333333;font-size:28px;margin-top:20px;margin-bottom:20px;text-align:center}p{color:#666666;font-size:16px;margin-bottom:20px;text-align:justify}a{color:#007bff;text-decoration:none}button{display:block;margin:0 auto;padding:10px 20px;background-color:#007bff;color:#ffffff;font-size:16px;border:none;border-radius:5px;cursor:pointer}</style></head><body><h1>Example Email with Link</h1><p>Dear [Name],</p><p>We are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.</p><p>Please click the button below to confirm your acceptance of the offer:</p><button><a href=\"https://example.com/accept_offer\">Accept Offer</a></button><p>If you have any questions or concerns, please do not hesitate to contact us at <a href=\"mailto:[email protected]\">[email protected]</a>.</p><p>Best regards,</p><p>[Your Name]<br>[Company Name]</p></body></html>",
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"subject": "Example email with HTML",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'Email dengan Attachment
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyHtml": "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>Example Email with Link</title><style>body{font-family:Arial,sans-serif;background-color:#f5f5f5}h1{color:#333333;font-size:28px;margin-top:20px;margin-bottom:20px;text-align:center}p{color:#666666;font-size:16px;margin-bottom:20px;text-align:justify}a{color:#007bff;text-decoration:none}button{display:block;margin:0 auto;padding:10px 20px;background-color:#007bff;color:#ffffff;font-size:16px;border:none;border-radius:5px;cursor:pointer}</style></head><body><h1>Example Email with Link</h1><p>Dear [Name],</p><p>We are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.</p><p>Please click the button below to confirm your acceptance of the offer:</p><button><a href=\"https://example.com/accept_offer\">Accept Offer</a></button><p>If you have any questions or concerns, please do not hesitate to contact us at <a href=\"mailto:[email protected]\">[email protected]</a>.</p><p>Best regards,</p><p>[Your Name]<br>[Company Name]</p></body></html>",
"bodyText": "Example Email with Link\n\nDear [Name],\n\nWe are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.\n\nPlease click the following link to confirm your acceptance of the offer:\n\nAccept Offer (https://example.com/accept_offer)\n\nIf you have any questions or concerns, please do not hesitate to contact us at [email protected].\n\nBest regards,\n\n[Your Name]\n[Company Name]",
"attachments": [
{
"mimeType": "image/png",
"filename": "FILE_NAME.png",
"value": "BASE64_ENCODED_CONTENT"
}
],
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"subject": "Example email with Attachment",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'Email dengan Attributes
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyHtml": "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>Example Email with Link</title><style>body{font-family:Arial,sans-serif;background-color:#f5f5f5}h1{color:#333333;font-size:28px;margin-top:20px;margin-bottom:20px;text-align:center}p{color:#666666;font-size:16px;margin-bottom:20px;text-align:justify}a{color:#007bff;text-decoration:none}button{display:block;margin:0 auto;padding:10px 20px;background-color:#007bff;color:#ffffff;font-size:16px;border:none;border-radius:5px;cursor:pointer}</style></head><body><h1>Example Email with Link</h1><p>Dear [Name],</p><p>We are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.</p><p>Please click the button below to confirm your acceptance of the offer:</p><button><a href=\"https://example.com/accept_offer\">Accept Offer</a></button><p>If you have any questions or concerns, please do not hesitate to contact us at <a href=\"mailto:[email protected]\">[email protected]</a>.</p><p>Best regards,</p><p>[Your Name]<br>[Company Name]</p></body></html>",
"bodyText": "Example Email with Link\n\nDear [Name],\n\nWe are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.\n\nPlease click the following link to confirm your acceptance of the offer:\n\nAccept Offer (https://example.com/accept_offer)\n\nIf you have any questions or concerns, please do not hesitate to contact us at [email protected].\n\nBest regards,\n\n[Your Name]\n[Company Name]",
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
// to track the email has been opened and the object in the content has been clicked
"optionsAttributes": {
"clickTracking": true,
"openTracking": true
},
"subject": "Example email with Attributes",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'Email dengan Header
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyText": "Example Email with Link\n\nDear [Name],\n\nWe are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.\n\nPlease click the following link to confirm your acceptance of the offer:\n\nAccept Offer (https://example.com/accept_offer)\n\nIf you have any questions or concerns, please do not hesitate to contact us at [email protected].\n\nBest regards,\n\n[Your Name]\n[Company Name]",
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"subject": "Example email with bodytext",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"headers":[
{
"name":"",
"value":""
}
]
}'Email dengan CC
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyText": "Example Email with Link\n\nDear [Name],\n\nWe are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.\n\nPlease click the following link to confirm your acceptance of the offer:\n\nAccept Offer (https://example.com/accept_offer)\n\nIf you have any questions or concerns, please do not hesitate to contact us at [email protected].\n\nBest regards,\n\n[Your Name]\n[Company Name]",
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"subject": "Example email with bodytext",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"cc":[
{
"email":"RECIPIENT_EMAIL",
"name":"RECIPIENT_NAME"
},
{
"email":"RECIPIENT_EMAIL",
"name":"RECIPIENT_NAME"
}
]
}'Email dengan BCC
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"bodyText": "Example Email with Link\n\nDear [Name],\n\nWe are pleased to inform you that you have been selected for the [Position] role at [Company Name]. Your skills and experience make you an excellent fit for the position, and we look forward to having you join our team.\n\nPlease click the following link to confirm your acceptance of the offer:\n\nAccept Offer (https://example.com/accept_offer)\n\nIf you have any questions or concerns, please do not hesitate to contact us at [email protected].\n\nBest regards,\n\n[Your Name]\n[Company Name]",
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"subject": "Example email with BCC",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"bcc":[
{
"email":"RECIPIENT_EMAIL",
"name":"RECIPIENT_NAME"
},
{
"email":"RECIPIENT_EMAIL",
"name":"RECIPIENT_NAME"
}
]
}'Email dengan Template ID
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer token' \
--data-raw '{
"from": {
"email": "[email protected]",
"name": "Sandbox Dev"
},
"templateId":"TEMPLATE_ID",
"substitutionData":{
"shortcode":"SHORTCODE_VALUE"
},
"subject": "Example Email with Template ID",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'