[SOLVED] Trying to send an email

I’m trying to send an email from the cloud functions, Sendgrid is all set up, the API key and email address is set in settings, the functions triggers an event that is recored in the data base, but no email is sent.

const logger = Moralis.Cloud.getLogger();
logger.info("Hello World");

Moralis.Cloud.afterSave("AuctionCreated", async (request) => {

  Moralis.Cloud.define("sendEmailToUser", function (request) {
    Moralis.Cloud.sendEmail({
      to: "**@***********.com",
      subject: "Test",
      html: "Test"
    });
  });

  })

Server:
https://witiy4l01xiz.usemoralis.com:2053/server

Try just:

Moralis.Cloud.afterSave("AuctionCreated", async (request) => {

    Moralis.Cloud.sendEmail({
      to: "**@***********.com",
      subject: "Test",
      html: "Test"
    });

  })

Try just sending an email (Moralis.Cloud.sendEmail) outside of the afterSave in a cloud function to make sure it works if you haven’t.

Great that works, thanks