javascriptnode.jsnodemailer

Nodemailer - Emails send but i do not recieve them


I am working on a project that uses nodemailer, when i submit the form, i get a 200 sucess and no errors from nodemailer but i don not recieve the email in my mail.

import nodemailer from "nodemailer";


const Email = (options) => {
    let transporter = nodemailer.createTransport({
        name: 'darciangn@gmail.com',
        service: "gmail",
        host: "smtp.gmail.com",
        port: 587,
        secure: false,
        auth:{
            user:'user',
            pass:'password',
        }
    })
     
    transporter.sendMail(options, (err, info) => {
        if (err) {
            console.log(err);
            return;
        }
        console.log("Email sent: " + info.response); // Log success message
    });
};

//SEND EMAIL
const EmailSender = ({firstName, lastName, email, companyName, typeOfDeveloper, recruitmentType}) => {
    const options = {
        from: `Darcia⚜️`,
        to: `darciangn@gmail.com`,
        subject: "Message from Darcia",
        html:`
    <div style="width: 100%; background-color: #f3f9ff; padding: 5rem 0">
        <div style="max-width: 700px; background-color: #feffe1; margin: 0 auto; background-image: url('https://res.cloudinary.com/dlxrzazn6/image/upload/v1725041898/jepdinustkmgor5cltdp.png'); background-repeat: no-repeat; background-size: 50%; background-position: 130% 300%;">
          <div style="width: 100%; background-color: #2b2b2b; padding: 20px 0">
          <a href="https://darcia-frontend.vercel.app" >
            <img
              src="https://res.cloudinary.com/dlxrzazn6/image/upload/v1725043148/mmciecekert56v0xc3y9.png"
              style="width: 100%; height: 70px; object-fit: contain"
            />
        </a> 
          
          </div>
          <div style="width: 100%; gap: 10px; padding: 30px 0; display: grid">
            <p style="font-weight: 800; font-size: 1.2rem; padding: 0 30px">
              Darcia hiring agnecy
            </p>
            <div style="font-size: .8rem; margin: 0 30px">
                <p>FullName: <b>${firstName}</b> <b>${lastName}</b></p>
                <p>Email: <b>${email}</b></p>
                <p>CompanyName: <b>${companyName}</b></p>
                <p>Type of Developer: <b>${typeOfDeveloper}</b></p>
                <p>Recruitment type: <b>${recruitmentType}</b></p>
            </div>
          </div>
        </div>
      </div> 
        `

    };
    Email(options)
}

export default EmailSender;

i have tried using a different mailing service and even changing the host and port but nothing


Solution

  • As I know google disabled support for “less secure” and you can't set it with personal email box on gmail. I'm not sure that it'll fix your issue but read this topic.

    https://nodemailer.com/usage/using-gmail/

    I think OAuth2 can be a right solution. It says:

    To prevent having login issues you should either use OAuth2 (see details here) or use another delivery provider and preferably a dedicated one.

    https://nodemailer.com/smtp/oauth2/