Email Send and Decode#

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

Note

For converting email to PDF please see PDF from Email.

/email/send#

  • Method: POST

  • Endpoint: /v1/email/send

Attributes#

Note

Attributes are case-sensitive and should be inside JSON for POST request, for example:

{
    "url": "https://example.com/file1.pdf"
}

Attribute

Description

Required

url

URL to the source file. 1

yes

from

The “From” field with sender name and email, e.g. John Doe.

yes

to

The “To” field with receiver name and email, e.g. Partner.

yes

subject

The subject for the outgoing email.

yes

bodytext

The plain text version of the outgoing email message.

no

bodyhtml

HTML version of the outgoing email message.

no

smtpserver

SMTP server address.

yes

smtpport

SMTP port.

yes

smtpusername

SMTP server username

yes

smtppassword

SMTP server password, If you use Gmail then you need to generate an app-specific password.

yes

async

Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint to check the status of the process and retrieve the output while you can proceed with other tasks.

no

profiles

Use this parameter to set additional configurations for fine-tuning and extra options. Explore the Profiles section for more.

no

Query parameters#

No query parameters accepted.

Payload#

{
   "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/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
}

Response 2#

{
   "error": false,
   "status": 200,
   "remainingCredits": 60095
}

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://pdfco-test-files.s3.us-west-2.amazonaws.com/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
}'


/email/decode#

  • Method: POST

  • Endpoint: /v1/email/decode

Attributes#

Note

Attributes are case-sensitive and should be inside JSON for POST request, for example:

{
    "url": "https://example.com/sample.eml"
}

Attribute

Description

Required

url

URL to the source file. 1

yes

inline

Set to true to return results inside the response. Otherwise, the endpoint will return a link to the output file generated. Note: only applies if async mode is true.

no

async

Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint to check the status of the process and retrieve the output while you can proceed with other tasks.

no

profiles

Use this parameter to set additional configurations for fine-tuning and extra options. Explore the Profiles section for more.

no

Query parameters#

No query parameters accepted.

Payload#

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

Response 2#

{
   "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
}

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://pdfco-test-files.s3.us-west-2.amazonaws.com/email-extractor/sample.eml",
    "inline": true,
    "async": false
}'


/email/extract-attachments#

  • Method: POST

  • Endpoint: /v1/email/extract-attachments

Attributes#

Note

Attributes are case-sensitive and should be inside JSON for POST request, for example:

{
    "url": "https://example.com/sample.eml"
}

Attribute

Description

Required

url

URL to the source file. 1

yes

inline

Set to true to return results inside the response. Otherwise, the endpoint will return a link to the output file generated. Note: only applies if async mode is true.

no

async

Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint to check the status of the process and retrieve the output while you can proceed with other tasks.

no

profiles

Use this parameter to set additional configurations for fine-tuning and extra options. Explore the Profiles section for more.

no

Query parameters#

No query parameters accepted.

Payload#

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

Response 2#

{
   "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
}

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://pdfco-test-files.s3.us-west-2.amazonaws.com/email-extractor/sample.eml",
    "inline": true,
    "async": false
}'


Code samples#

Footnotes

1(1,2,3)

Supports links from Google Drive, Dropbox, and PDF.co Built-In Files Storage. To upload files via the API check out the File Upload section. Note: If you experience intermittent Too Many Requests or Access Denied errors, please try to add cache: to enable built-in URL caching. (e.g cache:https://example.com/file1.pdf) For data security, you have the option to encrypt output files and decrypt input files. Learn more about user-controlled data encryption.

2(1,2,3)

Main response codes as follows:

Code

Description

200

Success

400

Bad request. Typically happens because of bad input parameters, or because the input URLs can’t be reached, possibly due to access restrictions like needing a login or password.

401

Unauthorized

402

Not enough credits

445

Timeout error. To process large documents or files please use asynchronous mode (set the async parameter to true) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using the pages parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.