Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Send mail after save for each user-email in collection

default discord avatar
zochhlast year
2

Hello, this is my code right now, I've got all the emails, but I'm confused with setting up the nodemailer part. I have my own STMP server with SSL, port: 465. How would I go setting it up?


const Posts: CollectionConfig = {
  // fields, admin and such
  hooks: {
    afterChange: [
      async (args) => {
        const emails = await payload
          .find({
            collection: "newsletter-emails",
            where: {
              and: [
                {
                  unsub: {
                    equals: false,
                  },
                },
              ],
            },
            limit: 9999,
          })
          .then((res) => res.docs);
      },
    ],
  },
};

export default Posts;
  • discord user avatar
    denolfe
    last year

    You would configure a nodemailer SMTP transport as documented here:

    https://nodemailer.com/smtp/


    Then you'd pass that email transport in your config

    email

    property or in

    init

    . Both are supported.

  • default discord avatar
    zochhlast year

    Yep, thanks- I've done that but the reason for not working was I misspelled

    STMP

    , wrote

    SMTP

    insread

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team..