Bạn có thể gửi email giao dịch bằng cách sử dụng API của chúng tôi với cURL. Trong mỗi email mà bạn gửi, bạn có thể sử dụng loại văn bản email, email HTML, email kèm tệp đính kèm, v.v.
Endpoint
cùng Tất cả các cuộc gọi đến API cần bắt đầu bằng URL cơ sở phù hợp. Bạn có thể chọn sử dụng URL bắt đầu cơ sở của chúng tôi hoặc URL cơ sở sản xuất trong quá trình triển khai.
Mailtarget production |
Sending options
Email with Body Text
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"subject": "Example email with Body Text",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"metadata":{
"key1": "METADATA_VALUE1",
"key2": "METADATA_VALUE2",
}
}'HTML email
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"subject": "Example email with HTML",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'Email with Attachment
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"subject": "Example email with Attachment",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'Email with Attributes
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
// 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 with Header
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"subject": "Example email with Headers",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"replyTo": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
],
"headers":[
{
"name":"HEADERS_NAME",
"value":"HEADERS_VALUE"
}
]
}'Email with CC
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"subject": "Example email with CC",
"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 with BCC
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--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": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"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 with Template ID
curl --location 'https://transmission.mailtarget.co/v1/layang/transmissions' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API_KEY' \
--data-raw '{
"from": {
"email": "SENDER_EMAIL",
"name": "SENDER_NAME"
},
"templateId":"TEMPLATE_ID",
"substitutionData":{
"shortcode":"SHORTCODE_VALUE"
},
"subject": "Example Email with Template ID",
"to": [
{
"email": "RECIPIENT_EMAIL",
"name": "RECIPIENT_NAME"
}
]
}'