Skip to content

ENHANCEMENT in the email.js #193

@SoumyaSubhrajit

Description

@SoumyaSubhrajit

If you have the issue in the emai.js, you can't send the email in the respective sender, just add this try and catch block in the await section. If you find helpful or have any bug let me know..

const nodemailer = require('nodemailer');

const sendEmail = async option => {
  // CRREATE A TRNSPORTER..
  const transport = nodemailer.createTransport({
    host: "sandbox.smtp.mailtrap.io",
    port: 2525,
    auth: {
      user: "5a64213903a459",
      pass: "9501fec9e11b1f"
    }
  });

  // DEFINE THE EMAIL.. 

  const mailOption = {
    from: 'Soumya <[email protected]>',
    to: option.email,
    subject: option.subject,
    text: option.message
  }

  // SEND THE EMAIL..
  try {
    await transport.sendMail(mailOption);
    console.log("The email has been sent!");
  } catch (error) {
    console.error(error);
  }
}

module.exports = sendEmail;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions