Hi there everyone!
I'm new to PayloadCMS and I'm trying to build a new webapp. I arrived at the step where I try to implement email verification, although I'm encountering a strange error I cannot understand... That's why I wanted to ask for your help!
I'm using resend and the custom NodeMailer transport (
https://payloadcms.com/docs/email/overview#use-a-custom-nodemailer-transport).
Here is the following setup for email verification I have made :
Payload version : 2.5.0
I observe the following behaviour when the user is created (should I precise user is indeed created):
TypeError: req.get is not a function
at sendVerificationEmail (C:\git\myapp\node_modules\payload\src\auth\sendVerificationEmail.ts:35:36)
at create (C:\git\myapp\node_modules\payload\src\collections\operations\create.ts:269:28)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
⨯ unhandledRejection: TypeError: req.get is not a function
at sendVerificationEmail (C:\git\myapp\node_modules\payload\src\auth\sendVerificationEmail.ts:35:36)
at create (C:\git\myapp\node_modules\payload\src\collections\operations\create.ts:269:28)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
⨯ unhandledRejection: TypeError: req.get is not a function
at sendVerificationEmail (C:\git\myapp\node_modules\payload\src\auth\sendVerificationEmail.ts:35:36)
at create (C:\git\myapp\node_modules\payload\src\collections\operations\create.ts:269:28)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Expected behaviour:
Email should be sent
It might be something very simple I missed!
Setup :
Transporter :
const transporter = nodemailer.createTransport({
host: 'smtp.resend.com',
secure: true,
port: 465,
auth: {
user: 'resend',
pass: process.env.RESEND_API_KEY,
},
})
Payload init:
cached.promise = payload.init({
email: {
transport: transporter,
fromAddress: 'mymail@domain.mail',
fromName: 'MyApp',
},
secret: process.env.PAYLOAD_SECRET,
local: initOptions?.express ? false : true,
...(initOptions || {}),
})
User model:
const Users: CollectionConfig = {
slug: "users",
auth: {
verify:{
generateEmailHTML: ({req, token, user}) => {
// Use the token provided to allow your user to verify their account
const url = `https://yourfrontend.com/verify?token=${token}`
return `Hey ${user.email}, verify your email by clicking here: ${url}`
}
}
},
access: {
read: () => true,
create: () => true,
},
fields:[
{
name: "role",
defaultValue: "user",
required: true,
type: "select",
options: [
{label: "Admin", value: "admin"},
{label: "User", value: "user"}
]
},
{
name: "username",
required: true,
type: "text"
}
]
}
nvm, I had to post this issue only to find out where the error was! Had an error when setting up the server URL in the buildConfig...
Star
Discord
online
Get dedicated engineering support directly from the Payload team.