Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENHANCEMENT in the email.js #193

Open
SoumyaSubhrajit opened this issue Apr 28, 2023 · 0 comments
Open

ENHANCEMENT in the email.js #193

SoumyaSubhrajit opened this issue Apr 28, 2023 · 0 comments

Comments

@SoumyaSubhrajit
Copy link

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant