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 email to user after create request using payload

default discord avatar
bhavikak.4 months ago
4

is it possible when user subscribe by email after post request i want to send email



Thanks

@967118574445547650

. I'll Try This.



can we send proper email template?



and is anything else that i have to do for send email to end user?



okay i'll try, Thanks

@967118574445547650

hello

@967118574445547650

we have tried with your given hook example but it's not working.



can you give me a full example or perfect reference.



we want to use google service for email

  • default discord avatar
    Payload-Botlast year
  • discord user avatar
    tylandavis
    last year
    @1043125033519820902

    You can use a

    beforeChange

    or

    afterChange

    Hook that runs during a

    create

    operation on your collection.

  • discord user avatar
    denolfe
    last year

    Here is a code snippet example of a collection afterchange hook:



    hooks: {
        afterChange: [
          ({ operation, req }) => {
            if (operation === 'create') {
              req.payload.sendEmail({
                to: 'john@doe.com',
                from: 'test@test.com',
                subject: 'Welcome!',
                text: 'Thank you for subscribing',
              });
            }
          },
        ],
      },


    @1043125033519820902

    sendEmail can accept an

    html

    property that can be a full email template you've created.



    For email sending, you'll need to hook up a proper email service. Docs here:

    https://payloadcms.com/docs/email/overview#email-functionality

    but it's not working.

    You'll need to be more specific.



    we want to use google service for email

    You'll need to use nodemailer's OAuth2 transport in order to send email using Gmail. Their docs on configuration are here:

    https://nodemailer.com/smtp/oauth2/

    In all honesty, unless you

    really need to send emails from gmail

    , I'd recommend going with another provider for sending email like Resend, SendGrid, or similar. The OAuth configuration for nodemailer looks cumbersome.

  • default discord avatar
    zainulmbrk.5 months ago

    Hey everyone, I’m new to this community. I’m working with Payload CMS and facing a problem with the replyTo header. I checked the inbox, but the replyTo is not there. thank you🙏

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.