ข้ามไปที่เนื้อหาหลัก

cURL

P
เขียนโดย Product Support
อัปเดตแล้วเมื่อวานนี้

คุณสามารถส่งอีเมลธุรกรรมโดยใช้ API ของเรากับ cURL โดยในแต่ละอีเมลที่คุณส่ง คุณสามารถใช้รูปแบบเนื้อหาอีเมล, HTML ของอีเมล, อีเมลพร้อมไฟล์แนบ ฯลฯ

ปลายทาง

การเรียกใช้ API ทั้งหมดต้องเริ่มต้นด้วย URL ฐานที่เหมาะสม คุณสามารถเลือกใช้ URL ฐานของแซนด์บ็อกซ์หรือ URL ฐานการผลิตของเราในระหว่างการติดตั้ง:

ตัวเลือกการส่ง

  1. อีเมลพร้อมข้อความเนื้อหา

    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",
    }
    }'

  2. อีเมล HTML

    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"
    }
    ]
    }'

  3. อีเมล์พร้อมไฟล์แนบ

    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"
    }
    ]
    }'

  4. อีเมล์พร้อมคุณลักษณะ

    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"
    }
    ]
    }'

  5. อีเมลพร้อมส่วนหัว

    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"
    }
    ]
    }'

  6. อีเมล์ด้วย 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"
    }
    ]
    }'

  7. อีเมล์ด้วย 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"
    }
    ]
    }'

  8. อีเมลพร้อม 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"
    }
    ]
    }'
นี่ไม่ใช่คำตอบที่ต้องการใช่ไหม