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.
Available Methods#
/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 to the source file. 1 |
yes |
|
The “From” field with sender name and email, e.g. |
yes |
|
The “To” field with receiver name and email, e.g. |
yes |
|
The subject for the outgoing email. |
yes |
|
The plain text version of the outgoing email message. |
no |
|
HTML version of the outgoing email message. |
no |
|
SMTP server address. |
yes |
|
SMTP port. |
yes |
|
SMTP server username |
yes |
|
SMTP server password, If you use Gmail then you need to generate an app-specific password. |
yes |
|
Set |
no |
|
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
}
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 to the source file. 1 |
yes |
|
Set to |
no |
|
Set |
no |
|
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 to the source file. 1 |
yes |
|
Set to |
no |
|
Set |
no |
|
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.gcache: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)
Response codes as follows:
Code
Description
200
The request has succeeded
400
Bad input parameters
401
Unauthorized
403
Not enough credits
405
Timeout error. To process large documents or files please use asynchronous mode (set the
async
parameter totrue
) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using thepages
parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.