Email sending error: Invalid username and password

Encountering this issue in Postman:

{
     "code": "EAUTH",
     "response": "535-5.7.8 Username and Password not accepted. More information available at\n535 5.7.8  
                  https://support.google.com/mail/?p=BadCredentials x7- 
                  20020aa784c7000000b005058d220b37sm21945855pfn.64 - gsmtp",
     "responseCode": 535,
     "command": "AUTH PLAIN"
}

 

Email And password not accepted, I have already gone through this question, and attempted various solutions to fix the issue, but none have been successful.

Nodemailer code snippet:

let transporter = nodemailer.createTransport({
   host: 'smtp.gmail.com',
   port: 587,
   secure: false,
   auth: {
     user:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a7cadec0cac6cecbe7c0cac6cecb89c4c8ca">[email protected]</a>',
     pass: 'mypassword'
   }
})

const info = await transporter.sendMail({
       from:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c21352b212d25200c2b212d2520622f2321">[email protected]</a>',
       to: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4b4a1b6b7abaa84a3a9a5ada8eaa7aba9">[email protected]</a>",
       subject: "subject",
       text: "text",
       html: `<h1> hello </h1>`
})

Steps taken:

  • Generated an app-specific password and substituted it for the actual password.

  • Enabled captcha (link)

  • Enabled IMAP setting in Gmail->Settings->Forwarding and POP/IMAP

Referenced less secure app and Google account

Any assistance will be greatly appreciated.

Answer №1

  • To begin, ensure you are using a valid Gmail account with your own credentials.
  • Make sure to enable access for less secure apps in your Google account settings by visiting this link: Allow less secure apps From your Google Account

const nodemailer = require('nodemailer');

const sendEmail = async () => {
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
  user: 'sender gmail',
  pass: 'sender password',
  },
});

const options = {
from: 'sender gmail',
to: 'receiver gmail',
subject: 'subject',
text: 'text',
};

await transporter.sendMail(options);
}; 

module.exports = sendEmail;

Answer №2

It is no longer possible to log in to the SMTP server using a username and password. One alternative could be using an app-specific password, but with Less secure apps & your Google Account being phased out soon, this may not be the most reliable option.

https://i.sstatic.net/crJZh.png

My suggestion would be to explore Xoauth2 as a way to authorize users without depending on their passwords. Consider adapting the javascript-implicit-flow model according to this guide.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Javascript to add hovering effects that demonstrate sophistication and style

I have a question : Here is the HTML code snippet: <div class="a b"> <span class="one">Success ONE</span> <span class="two">ONE</span> </div> <div class="a b"> <span class="one">Success TWO< ...

Remove search results in real-time

I'm currently working on implementing a search feature for a web application. While I have made some progress, I am facing an issue with removing items when the user backspaces so that the displayed items match the current search query or if the searc ...

Addressing file routes within my personalized npm bundle

I am in the process of developing a custom npm package called packer and experimenting with a configuration similar to webpack, where users can install my CLI tool to build their packages. Here is an example of a package.json file for a test package using ...

Transmitting data of a substantial size across different origins

I developed a JavaScript bookmarklet that generates a screenshot of an element and stores it as a base64 encoded string. However, I am faced with the challenge of sending this image/string to my server for storage because it consists of over 6000 characte ...

Creating a search bar with React-Redux: A step-by-step guide

Hey everyone, I've got this component here: const Iphone = ({phones,searchQuery}) => { const filterIphone = phones.map((p, index) => (<div className="model" key={index}> <NavLink to={'/p/' + p.id}>{p.body.mod ...

Using an array of objects to set a background image in a Bootstrap carousel using jQuery: a step-by-step guide

I have an array of items, each containing a background property with a URL to an image. Here is my array: https://i.sstatic.net/jfrV0.png Here is the HTML structure: <div id="myCarousel" class="carousel slide" data-ride="carousel"> <ol ...

Updating React props using useState?

Below is a component that aims to enable users to update the opening times of a store. The original opening times are passed as a prop, and state is created using these props for initial state. The goal is to use the new state for submitting changes, while ...

trouble with fetching data

Within my Backbone view, I have the following code snippet: var BookView = Backbone.View.extend({ initialize: function() { this.render(); }, render: function() { this.model.fetch({ success : function(model, resp, opt) { alert(this.$el. ...

The placement of Bootstrap Datepicker is experiencing issues

I have integrated the Bootstrap Datepicker from Eternicode into my ASP.Net MVC website. While the functionality is working well, I am facing difficulty in positioning the datepicker modal using the orientation option mentioned in the documentation and code ...

Ensuring validation for a single checked checkbox in AngularJS

I'm currently experiencing a challenge with checkboxes in my Angular project. Due to the requirements of the backend, each checkbox must have a unique name, but at least one of them needs to be checked before the form can be submitted. To address thi ...

utilization of 'return on' in a jQuery tool

I'm currently working on a simple jQuery plugin. The interesting thing is, the plugin functions perfectly fine even without using the return keyword. However, I noticed that on the jQuery website, they always use return when creating a plugin. So my q ...

Extracting Data from Input Box Using Query

In my HTML setup, I have five <textarea> tags with IDs text1,text2,text3,text4, and one additional <textarea> tag with ID output. I want to query based on the values of text1,text2,text3,text4 (referred to as field1, field2, field3, field4). F ...

Struggling to locate the module 'firebase-admin/app' - Tips for resolving this issue?

While working with Typescript and firebase-admin for firebase cloud functions, I encountered the error message "Cannot find module 'firebase-admin/app'" when compiling the code with TS. Tried solutions: Reinstalling Dependency Deleting node_modu ...

Navigate post Ajax call

When I make an unauthenticated GET request using AJAX, my server is supposed to redirect my application. However, when I receive the redirect (a 303 with /login.html as the location), the response tab in the Firebug console shows me the full HTML of the lo ...

The total sum of values within labels that share the same class

I am attempting to sum up all the values of class tmpcpa and store the result in final_cpa, but for some reason final_cpa always ends up being 0. document.getElementById('cpa' + arr[0]).innerHTML = cpa + '(' + '<label id="tmp ...

Ensuring maximum length validation on input

I am having an issue with the function "checkNumbers()". I am attempting to validate if my input does not exceed 10 numbers; while "isAllowedSymbol()" is functioning correctly, the other one is not. What could be causing this problem? function isAllowe ...

Retrieve a specific key from SQL records

I have recently started learning JavaScript and MySQL. When I run a MySQL query in my server-side JavaScript code, the returned rows are in the following format: For example, if I use console.log(rows), it will display: [ RowDataPacket { id: 7080, ...

Are beta versions included in the "latest" versions of package.json?

Within the package.json file, you have the option to define a package to be synchronized with the most recent version: { ..., "devDependencies": { "gulp": "latest", ... }, ... } When "latest" is specified, does it encompass alpha ...

When Google Chrome encounters two variables or functions with the same name, how does it respond?

I am curious what happens when Google Chrome encounters two variables with the same name. In my particular case, this issue arises in the code snippet available at this link, which is a small portion of the entire code. I am facing an issue where placing C ...

Converting a string to an array in React when updating the state

Currently, I am working on a React CRUD app that allows me to manage dishes. I can add new dishes, display a list of existing ones, update the details of a dish, or delete a dish. My main challenge at the moment is updating the ingredients of a dish. Whil ...