<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muhammed Sahad</title>
    <description>The latest articles on DEV Community by Muhammed Sahad (@mhmd_sahad).</description>
    <link>https://dev.to/mhmd_sahad</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3327565%2Fdd80845c-3f02-4348-b243-775c7028370c.jpg</url>
      <title>DEV Community: Muhammed Sahad</title>
      <link>https://dev.to/mhmd_sahad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mhmd_sahad"/>
    <language>en</language>
    <item>
      <title>Node.js Emailing: Get Started with Nodemailer</title>
      <dc:creator>Muhammed Sahad</dc:creator>
      <pubDate>Sun, 06 Jul 2025 06:52:57 +0000</pubDate>
      <link>https://dev.to/mhmd_sahad/nodejs-emailing-get-started-with-nodemailer-3emj</link>
      <guid>https://dev.to/mhmd_sahad/nodejs-emailing-get-started-with-nodemailer-3emj</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Read This On Medium &lt;a href="https://medium.com/@muhammedsahad/node-js-emailing-get-started-with-nodemailer-5dccaed6eb3f" rel="noopener noreferrer"&gt;https://medium.com/@muhammedsahad/node-js-emailing-get-started-with-nodemailer-5dccaed6eb3f&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hey folks! In this quick tutorial, I’ll show you how to implement Nodemailer in just a few simple steps. It’s going to be a short and sweet guide, so let’s dive right in!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Nodemailer ?
&lt;/h2&gt;

&lt;p&gt;Nodemailer is a module for Node js applications for sending mails. you can check the official website here&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating App Password
&lt;/h2&gt;

&lt;p&gt;Before we begin, we need to setup the app password. A Google App Password is a 16-digit passcode that allows apps or devices that don’t support two-factor authentication (2FA) to connect to your Google account securely. so let create app password&lt;/p&gt;

&lt;p&gt;First login your Google Account Manger:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh8fijfanzqe8udlxfsu5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh8fijfanzqe8udlxfsu5.png" alt="Image description" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search for App Password:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fss29c75do3al48o8qh6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fss29c75do3al48o8qh6t.png" alt="Image description" width="800" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s create an app password&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpgzve1ipfl7xeng5tzgx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpgzve1ipfl7xeng5tzgx.png" alt="Image description" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The you can see the 16 digit password created keep it secure do not expose it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c4k4hqrc5n3kpjmp89l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c4k4hqrc5n3kpjmp89l.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Nodemailer
&lt;/h2&gt;

&lt;p&gt;Now, Lets setup the Nodemailer. We have Nodemailer package available in NPM. click here to see&lt;/p&gt;

&lt;h2&gt;
  
  
  Install nodemailer package
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i nodemailer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure Nodemailer&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var nodemailer = require("nodemailer");

var transporter = nodemailer.createTransport({
  service: "gmail",
  host: "smtp.gmail.com",
  port: 465,
  secure: true,
  auth: {
    user: process.env.RECIPIENT_EMAIL_ADDRESS,
    pass: process.env.RECIPIENT_EMAIL_PASSWORD,
  },
});

module.exports = transporter;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now replace with app password that you created and your email address with pass and user .&lt;/p&gt;

&lt;p&gt;Now we are gonna send email. i’ve a route called /send-mail&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
router.post("/send-mail", (req,res) =&amp;gt; {
  try {

      var mailOptions = {
        from: `jhon@gmail.com`,
        to: "sahadmuhammed289@gmail.com",
        subject: "Sending Email With Nodemailer",
        text: "Email Received!",
        name: "Jhon"
      };

      transporter.sendMail(mailOptions, (error, info) =&amp;gt; {
        if (error) {
          console.log(error);
        } else {
           console.log("Mail Sent!")
        }
      });
    } catch (error) {
      console.log("ERROR:", error);
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can see the mailOptions Object which held the info of our mail. replace to with email which you wanna receive the the emails. If any error happen when sending the email, the error in the sendMail logs it. if everything is work perfect you can get the email and the log “Mail sent”.&lt;/p&gt;

&lt;p&gt;Here is the result&lt;/p&gt;

&lt;h2&gt;
  
  
  That’s all ! 😃
&lt;/h2&gt;

&lt;h2&gt;
  
  
  If you got something from this post please clap and leave your doubts on comments. see you on next blog.
&lt;/h2&gt;

</description>
      <category>node</category>
      <category>backend</category>
      <category>nodemailer</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
