Docly Developers
Function API only Updated 23 Oct 2026

sendEmail(file, template, receiver, subject, message)

Produces a file using the specified template (HTML, PDF etc) and sends the output by email.

Parameters

filestringrequired

Absolute path to file.

templatestringrequired

Name of the template to use to generate this file's output.

receiverstring (email)required

To address for the email.

subjectstringrequired

Subject for the email.

messagestringrequired

Message for the email.

Returns

true if successful. Returns null when the file or its template is not found, and the text "Load failed for …" when the file cannot be loaded. A failed document generation, an access error or a send failure throws.

The email is sent through Docly's mail service. It has a monthly limit per subscription (when the subscription sets one), a daily limit per site and a per-minute rate limit. When a limit is reached the call throws error 8 ("E-mail limit for this site has been reached. The message was not sent."). sendEmail always uses Docly's mail service, so the limits always apply — use smtp.send with your own SMTP server to avoid them. The limit is checked before the document is generated.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
// Generate a PDF and send it
docly.sendEmail(
    "somefile", 
    "Contract.html.pdf", 
    "test@docly.net", 
    "Contract for rental", 
    "Here is the signed contract attached. See you soon!");