sendEmail(file, template, receiver, subject, message)
Produces a file using the specified template (HTML, PDF etc) and sends the output by email.
Parameters
filestringrequiredAbsolute path to file.
templatestringrequiredName of the template to use to generate this file's output.
receiverstring (email)requiredTo address for the email.
subjectstringrequiredSubject for the email.
messagestringrequiredMessage 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
// 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!");