Hello, Do you have any idea about how to add our own custom email sending functionalities for verify email and forgot password auth operations ?
Right now, we are doing the email configuraton in payload.init .
We don't want do it. So, We have to write our own email sending functionalities and configure with verify email and forgot password functionalities.
Do you have the solution , feel free to share . Thanks
Good morning @Veera26
On Auth-enbabled collections, you can override the generated email with something custom
https://payloadcms.com/docs/authentication/config#forgot-password
import { CollectionConfig } from 'payload/types';
export const Customers: CollectionConfig = {
slug: 'customers',
auth: {
forgotPassword: {
generateEmailHTML: ({ req, token, user }) => {
// Use the token provided to allow your user to reset their password
const resetPasswordURL = `https://yourfrontend.com/reset-password?token=${token}`;
return `
<!doctype html>
<html>
<body>
<h1>Here is my custom email template!</h1>
<p>Hello, ${user.email}!</p>
<p>Click below to reset your password.</p>
<p>
<a href="${resetPasswordURL}">${resetPasswordURL}</a>
</p>
</body>
</html>
`;
}
}
}
};
Okay
is there a way to disable the mockTransport email configuration ?
Hmm, I think you can disable it by setting logMockCredentials to false -
https://payloadcms.com/docs/email/overview#mock-transportuser.email giving me error "Property 'email' does not exist on type 'unknown'."
@s4chin Hmm that's odd, and just to confirm, that field is on the user collection right? (i think its mandated)
You may need to run the update types cmd, though I'm not sure on first look
Are you still having issues @s4chin
here it is
And yes I m still having this issue after updating types
@s4chin What happens when you log
user
Also, are you able to try logging
req.user
I can log in using email it just giving me type error thats all and I am able to see that email address in received email as well
Right, im trying to identify the type of User in this case and why it doesn't have an email property
Maybe because User can technically be null
Which would probably be fixed by wrapping the code in a condition like
"if (user)"
i think
user["email"] I did this and issue is solved
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.