Hello, I have added a link on my reactjs website for users, who forgot their login passwords, to click on the link so that a reset password link will be sent to each of them. But after I (assuming I am the user) clicked on the link, I didn’t get an email (which has a link to reset my login password) even though my mongodb database gets updated with a reset password link data added to my mongodb database each time a user click on the reset password link.
What API are you using to send out the email? SendGrid? Mailgun? If you’re hitting a backend server (e.g Express) then you may be using Nodemailer? If you’re in development, I tecommend Mailtrap for testing.
Hi Andrew, I am using Express and Nodemailer. How to fix the problem? Thanks.
There are several things that could be going wrong, not necessarily related to MongoDB –
As long as you can get the user’s email back from the database when you query it (via MongoDB’s own NodeJS Driver, fetch / axios, etc) on your backend and have it returned to your React app, then it’s probably not related to MongoDB.
If you are getting a response back, then you’ll need to make sure you are able to confirm receiving an email via a service like [Mailtrap] (https://mailtrap.io/) setup in your Nodemailer configuration.
Warning: Some services or systems might complain in your console about not being able to verify the server’s certificate (localhost) when sending email. If this is the case, you’ll need to update your Express server to appear secure (https vs http) by mocking out an SSL certificate. You can learn how to do that here.
Hi Andrew, I replaced my SMTP settings with mailtrap SMTP settings. Why is there an error?=
Unhandled Rejection (TypeError): Cannot read property ‘error’ of undefined
Hi Jen, at this point since the issue is more likely a React/JS-specific issue rather than having to do with MongoDB, I’d recommend joining this Discord server and posting the question there as you’ll get savvy React and JS devs (myself included ) who can help you work through the issue. Of course, once it’s resolved, it’s best to come back to this post and provide the solution and mark the thread resolved so other MongoDB Community members can see what the solution was should they be experiencing the same issue.
I tried Discord before asking another question but no reply. How then? Do I show you some of my nodemailer code here?
Best to share on Discord/Slack – I’ll look for you there. I messaged you for more info. I’ll try to help where I can.
My username is reactuser. When are you available to help me in Malaysia time? I see you there. Thanks!
Message me there so I have you on my radar. Your name was too generic as there are too many users with “reactuser” as their username.
What is your username? Thanks.