meabhisingh / mernProjectEcommerce

This is MERN Stack Ecommerce Project Made to Teach MERN Stack on YouTube
1.15k stars 826 forks source link

issue in sending email #52

Open sheikhumar122 opened 1 year ago

sheikhumar122 commented 1 year ago

error in postman shows this { "success": false, "message": "Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials k23-20020a63d857000000b0051b595b26adsm4865559pgj.91 - gsmtp" }

HetMamtora commented 1 year ago

You need to create App Specific password for it from Manage Account of your gmail to use it as SMTP.

zeeshan7791 commented 1 year ago

Error in the token when updating the password { "success": false, "message": "Reset Password Token is invalid or has been expired" }

sk394 commented 1 year ago

Go to your Google Account settings, navigate to the "Security" tab, and under the "Signing in to Google" section, click on "App passwords." Generate a new app password specifically for your Node.js application and use that password instead of your account's regular password in the SMTP_PASSWORD field. You can use the custom name for the app like "Node.js Email Application". Then, change your code like this:-> const transporter = nodeMailer.createTransport({ host:process.env.SMTP_HOST, port:process.env.SMTP_PORT, auth:{ user:process.env.SMTP_EMAIL, pass:process.env.SMTP_PASSWORD, } In the config file, SMTP_HOST = smtp.gmail.com SMTP_PORT = 465

Anmol-002 commented 7 months ago

@HetMamtora bro can u send me the env file of backend just what all you have written in it. I tried to upload it on render and my whole project is fucked up now i am getting 1000 errors. Can u just tell me what changes u made to upload it to some domain

HetMamtora commented 7 months ago

@HetMamtora bro can u send me the env file of backend just what all you have written in it. I tried to upload it on render and my whole project is fucked up now i am getting 1000 errors. Can u just tell me what changes u made to upload it to some domain

I can't share my raw env file. I will paste whole body with required data within the brackets. You can just copy paste your own keys and passwords into it.

HetMamtora commented 7 months ago

@HetMamtora bro can u send me the env file of backend just what all you have written in it. I tried to upload it on render and my whole project is fucked up now i am getting 1000 errors. Can u just tell me what changes u made to upload it to some domain

PORT= [MONGODB PORT NUMBER] DB_URI= [MONGODB DATABASE URL]

JWT_SECRET=dkjafbniuebfpibunfe98wyhr89wfendjsv JWT_EXPIRE=5d COOKIE_EXPIRE=5

SMPT_SERVICE=gmail SMPT_MAIL= [WHOLE EMAIL ADDRESS THAT YOU ARE USING AS SMTP eg. abc@gmail.com] SMPT_PASSWORD= [SET PASSWORD OR YOU CAN GET THE GENERATED PASSWORD FROM YOUR GMAIL ACCOUNT] SMPT_HOST=smtp.gmail.com SMPT_PORT= [YOUR SMTP PORT NUMBER]

CLOUDINARY_NAME= [CLOUDINARY SERVER NAME] CLOUDINARY_API_KEY= [SAME AS GIVEN ON CLOUDINARY] CLOUDINARY_API_SECRET= [SAME AS GIVEN ON CLOUDINARY]

FRONTEND_URL= [WHATEVER LOCALHOST URL THAT YOU ARE USING] STRIPE_API_KEY=pktest[SAME AS GIVEN ON STRIPE] STRIPE_SECRET_KEY=sktest[SAME AS GIVEN ON STRIPE]

Anmol-002 commented 7 months ago

@HetMamtora thanks a lot buddy. Can you also help me one thing. If we start the project without any previous login i am getting an error Failed to load resource: the server responded with a status of 401 (Unauthorized) for :3000/api/v1/stripeapikey:1 and :3000/api/v1/me. I had the same issue with my code so i ran yours and i am still encountering this error. Bro can u also tell me how have u hosted the website i mean what all changes u did before hosting

HetMamtora commented 7 months ago

@HetMamtora thanks a lot buddy. Can you also help me one thing. If we start the project without any previous login i am getting an error Failed to load resource: the server responded with a status of 401 (Unauthorized) for :3000/api/v1/stripeapikey:1 and :3000/api/v1/me. I had the same issue with my code so i ran yours and i am still encountering this error

First verify the login from postman. If it works then you will have to look for the issue in frontend. If it doesn't work then there's some issue in backend only.

I guess without login it wont work because of the login authentication we have set for the project. Another thing is there might be some dependencies issues over here as with JavaScript everyday new dependencies are introduced or older ones are updated. When I was doing this project It was already a year old and now with you doing this project it is nearly 2 years old project. Even when I was doing this project I had to use legacy peer deeps to install all the older dependencies, some of them worked some of them didn't so I left it. If my code helps you from my repository you can have a look at it. Other than that I don't have any other resource to help you.

Happy to help. Good Luck =)

devgoel2004 commented 1 month ago

Error in the token when updating the password { "success": false, "message": "Reset Password Token is invalid or has been expired" } you can use { withCredentials: true,} in the frontend while using axios requests.