Skip to content
Local environment Preproduction — not production data

Sending email

Factorial Code includes a built-in email helper so your processes can send email without configuring an SMTP server or managing credentials. The mail server and credentials live in the Factorial Code platform, never in your process.

Common uses:

  • Notifying users when a process finishes (reports, exports, alerts).
  • Sending error notifications from an error handler.
  • Delivering links to files kept in Storage.

fcode.sendMail (JavaScript) / fcode.send_mail (Python) sends an email and returns the delivery result. Provide text, html, or both; to accepts a single address or a list.

Sending an email
const info = await fcode.sendMail({
to: "[email protected]", // string or array of strings
subject: "Your report is ready",
text: "Plain-text body",
html: "<b>HTML body</b>",
});
// info => { messageId, accepted, rejected }

The platform decides per execution whether an email is delivered or caught, based on the workspace the process runs in. Your code does not change between the two cases: same call, same result object, and accepted lists the recipients in both.

  • From a customer’s production installation, the email is sent to the recipient.
  • From any other workspace, the email is caught in the dev mailbox and never delivered.

So you can send to real addresses while developing, from a scheduled process or from an error handler, without anyone receiving test mail.

Every caught email is kept, with its full headers, text and HTML bodies and attachments, in a mailbox you can open from your browser:

https://code.factorialhr.com/devmail/<team-slug>/

Sign in with your Factorial Code account. The mailbox shows only the email sent from that workspace, so you see the mail of the workspaces you belong to and nothing else. It is a development tool, not an archive: only the most recent messages are kept, and you can delete them at any time.