Category: How do I do X?

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

Is it possible to send emails when a specific event happens?


I am running a self-hosted docker instance of Appsmith and needed to send an email with data from a form whenever a user uploaded a file. I was wondering if it was possible to do this with JS. After receiving a suggestion to use a SMTP datasource and trigger the email in the onFilesSelected event of the FilePicker widget, I was able to solve my problem.


The solution involves using a SMTP datasource to send emails with the data contained in a form when a user uploads a file. The first step is to set up the SMTP datasource with the correct email settings. Then, in the onFilesSelected event of the FilePicker widget, the code can be added to send an email using the SMTP datasource and the data from the form.

The code might look something like this:

const formData = widgetName.formData;
const emailBody = "Form Data: " + JSON.stringify(formData);

const smtpDataSource = await getAppsmithDataSource("SMTP");

const email = {
to: "",
subject: "New File Uploaded",
body: emailBody,

smtpDataSource.sendEmail(email).then((response) => {

Replace "" with the email address of the recipient, and customize the subject and body of the email as needed.

Finally, make sure to test the code to ensure that the email is sent successfully when a user uploads a file.