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.

Issue setting up email service

default discord avatar
the_light_bearerlast year
9

I have tried using SMTP settings as displayed in the docs, also tried using the payload/email-nodemailer plugin and also sendmailer-sendgrid plugin



But even with defaultfromaddress provided the email sent do not have from address and the emails get rejected immediately.

  • default discord avatar
    qamarqlast year

    +1



    in version

    beta-29

    its making from header like:


    name <name>

    instead of correctone:


    name <email>

    btw same bugs have resend adapter

  • default discord avatar
    the_light_bearerlast year

    I updated all the way till beta 45



    With no luck



    Did you find a fix for this?

  • default discord avatar
    qamarqlast year

    yeah, for now set defaultFromAddress and defaultFromName to email

  • default discord avatar
    the_light_bearerlast year

    Let me give it a try



    Thanks that actually works



    I just now saw the PR for the same two



    Not sure how I missed it



    That works thank you



    Quick question the verify link shows a 404 error when clicked, is it broken as well?



    Or is there an additional setting or something that is missing in the documentation

  • default discord avatar
    qamarqlast year

    yeah



    u can custom it



    my code in users collection:



     auth: {
            tokenExpiration: 60 * 60 * 24,
            verify: {
                generateEmailHTML: async ({ req, token, user }) => {
                    const url = `${process.env.NEXT_PUBLIC_SERVER_URL}/auth/verify?token=${token}`
                    console.log('URL', url)
                    const email = SendRegisterEmailTemplate({ email: user.email, url })
                    const ReactDOMServer = (await import('react-dom/server')).default
                    return ReactDOMServer.renderToString(email);
    
                    // return `Hey ${user.email}, verify your email by clicking here: ${url}`
                },
            },
            forgotPassword: {
                generateEmailHTML: async ({ req, token, user }: any) => {
                    const url = `${process.env.NEXT_PUBLIC_SERVER_URL}/auth/reset-password?token=${token}`
                    console.log('URL', url)
    
                    // return `Hey ${user.email}, reset your password by clicking here: ${url}`
                    const email = SendVerifyEmailTemplate({ email: user.email, url })
                    const ReactDOMServer = (await import('react-dom/server')).default
                    return ReactDOMServer.renderToString(email);
                },
            },
            maxLoginAttempts: 5,
            lockTime: 600 * 1000
        },


    u returning html in these functions



    in my code im building it from react component



    @1014589523247771679
  • default discord avatar
    the_light_bearerlast year

    Thank you 🙏, I will give it a try and get back to you



    sorry I was on my phone so couldn't see the code, but that is what I am using as well more or less, but I was talking about the verification link itself, is /verify or /auth/verify a default and do I gotta set it somewhere cause when I use this link for example

    http://localhost:3000/auth/verify?token=6139102fe089c883481fc47398398369ac3e7b10

    it returns an 404 error

  • default discord avatar
    qamarqlast year

    Yes



    U must make a page



    And then call API reset password



    With token



    Pass



    And pass confirm

  • default discord avatar
    the_light_bearerlast year

    okay but what api? I is it the users api?



    and what do pass exactly just the token?



    I am sorry the documentation was not very clear on these things



    sorry never mind I seem to have missed that it was clearly documented here

    https://payloadcms.com/docs/authentication/operations


    Anyways thanks for all the help

  • default discord avatar
    qamarqlast year

    No problem

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.