Link Search Menu Expand Document

Email Send and Decode

Related Knowledgebase-Explore Samples

Functions to send email (with attachments), decode email, extract attachments from email.

For converting email to pdf please see /pdf/convert/from/email

Available Methods

[POST] /email/send

  • url optional. Link or links (comma separated) to be included as email attachments. Supports links to pdf.co output files, files from Google Drive, Dropbox. For uploading files via PDF.co API please check Files Upload section. If you are randomly getting Too Many Requests or Access Denied error for your input url, please try to add cache: to enable built-in url caching.
  • from required - from field with sender name and email, for example: John Doe
  • to required - to field with receiver name and email, e.g. Partner
  • subject required - subject for the outgoing email
  • bodytext plain text version of outgoing email message
  • bodyhtml html version of outgoing email message
  • smtpserver required smtp server address. To learn how to setup smtp details, please check here
  • smtpport smtp port. To learn how to setup smtp details, please check here
  • smtpusername required smtp server username. To learn how to setup smtp details, please check here
  • smtppassword required smtp server password. If you use Gmail then you need to generate app specific password as instructed here. To learn how to setup smtp details, please check here
  • async optional. Runs processing asynchronously. Returns JobId that you may use with /job/check to check state of the background job (possible states: working, failed, aborted and success). Must be one of: true, false.
  • profiles optional. Must be a String. Use this parameter to set additional configuration for fine tuning and extra options. Explore PDF.co knowledgebase for profile examples.

  • Method: POST
  • URL: /v1/email/send

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-info/sample.pdf",
    "from": "John Doe <john@example.com>",
    "to": "Partner <partner@example.com>",
    "subject": "Check attached sample pdf",
    "bodytext": "Please check the attached pdf",
    "bodyHtml": "Please check the attached pdf",
    "smtpserver": "smtp.gmail.com",
    "smtpport": "587",
    "smtpusername": "my@gmail.com", 
    "smtppassword": "app specific password created as https://support.google.com/accounts/answer/185833",
    "async": false
}

Example responses

/email/send
{
    "error": false,
    "status": 200,
    "remainingCredits": 60095
}

Code Snippet

CURL
curl --location --request POST 'https://api.pdf.co/v1/email/send' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/pdf-info/sample.pdf",
    "from": "John Doe <john@example.com>",
    "to": "Partner <partner@example.com>",
    "subject": "Check attached sample pdf",
    "bodytext": "Please check the attached pdf",
    "bodyHtml": "Please check the attached pdf",
    "smtpserver": "smtp.gmail.com",
    "smtpport": "587",
    "smtpusername": "my@gmail.com", 
    "smtppassword": "app specific password created as https://support.google.com/accounts/answer/185833",
    "async": false
}'

[POST] /email/decode

  • url required. URL to the source file. Supports links from Google Drive, Dropbox and from built-in PDF.co files storage. For uploading files via API please check Files Upload section. If you are randomly getting Too Many Requests or Access Denied error for your input url, please try to add cache: to enable built-in url caching. You can also encrypt data for output files and decrypt data input files with user-controlled data encryption (uses strong AES encryption with your own keys). Click here to learn more.
  • inline optional. false by default. In async mode it returns body with the content of the output json (with the links to the output).
  • async optional. Runs processing asynchronously. Returns JobId that you may use with /job/check to check state of the background job (possible states: working, failed, aborted and success). Must be one of: true, false.
  • profiles optional. Must be a String. Use this parameter to set additional configuration for fine tuning and extra options. Explore PDF.co knowledgebase for profile examples.

  • Method: POST
  • URL: /v1/email/decode

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/email-extractor/sample.eml",
    "inline": true,
    "async": false
}

Example responses

/email/decode
{
    "body": {
        "from": "test@example.com",
        "fromName": "",
        "to": [
            {
                "address": "test2@example.com",
                "name": ""
            }
        ],
        "cc": [],
        "bcc": [],
        "sentAt": null,
        "receivedAt": null,
        "subject": "Test email with attachments",
        "bodyHtml": null,
        "bodyText": "Test Email Message with 2 PDF files as attachments\r\n\r\n",
        "attachmentCount": 2
    },
    "error": false,
    "status": 200,
    "name": "sample.json",
    "remainingCredits": 60095
}

Code Snippet

CURL
curl --location --request POST 'https://api.pdf.co/v1/email/decode' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/email-extractor/sample.eml",
    "inline": true,
    "async": false
}'

[POST] /email/extract-attachments

  • url required. URL to the source file. Supports links from Google Drive, Dropbox and from built-in PDF.co files storage. For uploading files via API please check Files Upload section. If you are randomly getting Too Many Requests or Access Denied error for your input url, please try to add cache: to enable built-in url caching. You can also encrypt data for output files and decrypt data input files with user-controlled data encryption (uses strong AES encryption with your own keys). Click here to learn more.
  • inline optional. false by default. In async mode it returns body with the content of the output json (with the links to the output).
  • async optional. Runs processing asynchronously. Returns JobId that you may use with /job/check to check state of the background job (possible states: working, failed, aborted and success). Must be one of: true, false.
  • profiles optional. Must be a String. Use this parameter to set additional configuration for fine tuning and extra options. Explore PDF.co knowledgebase for profile examples.

  • Method: POST
  • URL: /v1/email/extract-attachments

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/email-extractor/sample.eml",
    "inline": true,
    "async": false
}

Example responses

POST /email/extract-attachments
{
    "body": {
        "from": "test@example.com",
        "subject": "Test email with attachments",
        "bodyHtml": null,
        "bodyText": "Test Email Message with 2 PDF files as attachments\r\n\r\n",
        "attachments": [
            {
                "filename": "DigitalOcean.pdf",
                "url": "https://pdf-temp-files.s3.amazonaws.com/2943e6bb80e646ec92e839292e95d542/DigitalOcean.pdf"
            },
            {
                "filename": "sample.pdf",
                "url": "https://pdf-temp-files.s3.amazonaws.com/e10e37fbb438432a83ece50ccdc719b3/sample.pdf"
            }
        ]
    },
    "pageCount": 2,
    "error": false,
    "status": 200,
    "name": "sample.json",
    "remainingCredits": 60085
}

Code Snippet

CURL
curl --location --request POST 'https://api.pdf.co/v1/email/extract-attachments' \
--header 'Content-Type: application/json' \
--header 'x-api-key: ' \
--data-raw '{
    "url": "https://bytescout-com.s3-us-west-2.amazonaws.com/files/demo-files/cloud-api/email-extractor/sample.eml",
    "inline": true,
    "async": false
}'

Knowledgebase

Samples