# Nodemailer for Namecheap Private Email

**URL:** <https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790>\
**Category:** General\
**Created:** [October 1, 2017, 7:15am UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790 "2017-10-01T07:15:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![publicalias](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/publicalias/32/52515_2.png) [@publicalias](https://forum.freecodecamp.org/u/publicalias)\
**Post date:** [October 1, 2017, 7:15am UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/1 "2017-10-01T07:15:41Z")

</div>

I decided to redo my portfolio–and all my other projects–halfway through the back-end certification. The last thing I have to do is set up the contact form. I’m using nodemailer and a namecheap mailbox. Everything works except the SMTP transporter:

```auto
var transporter = nodemailer.createTransport({
  host: "mail.privateemail.com",
  port: 587,
  secure: false,
  auth: {
    user: email,
    pass: password
  }
});

```

These are the only resources I’ve found:

- [https://nodemailer.com/smtp/](https://nodemailer.com/smtp/)
- [https://www.namecheap.com/support/knowledgebase/article.aspx/9142/2186/general-configuration-for-mail-clients-and-mobile-devices](https://www.namecheap.com/support/knowledgebase/article.aspx/9142/2186/general-configuration-for-mail-clients-and-mobile-devices)

When I test it with `transporter.verify()` and `transporter.sendMail()`, the only error message I get is when it times out after two minutes. If anyone has experience with nodemailer and/or namecheap, any insight you can give me would be a great help.

---

<div class="post-metadata">

**Author:** ![JacksonBates](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jacksonbates/32/123402_2.png) [@JacksonBates](https://forum.freecodecamp.org/u/JacksonBates)\
**Post date:** [October 1, 2017, 7:24am UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/2 "2017-10-01T07:24:16Z")

</div>

I didn’t have this exact problem, but I recall something similar with Namecheap and Sparkpost.

I contacted namecheap via their live chat support. They cleared up my issue very quickly…your mileage may vary 🙂

---

<div class="post-metadata">

**Author:** ![honmanyau](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/honmanyau/32/45787_2.png) [@honmanyau](https://forum.freecodecamp.org/u/honmanyau)\
**Post date:** [October 1, 2017, 12:51pm UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/3 "2017-10-01T12:51:01Z")

</div>

Whoa, this is really weird, I literally did the same a couple of days ago for my portfolio. o\_\_\_O

Anyhow! I’m with a different host but I have a feeling that your problem is not your code because it looks like what I have. I suggest that you double check your password and username (make sure that it’s indeed your email address—are you able to use the same credentials for a mail client?).

Below is the code that I’m currently using, and I’ve just tested that it works for both port 465 (`secure: true`) and 587 (`secure: false`):

```auto
  const transporter = nodemailer.createTransport({
    host: process.env.EMAIL_HOST,
    port: 465,
    secure: true,
    auth: {
      user: process.env.EMAIL_USER,
      pass: process.env.EMAIL_PASSWORD
    }
  });
  
  const mailOptions = {
    from: process.env.EMAIL,
    to: process.env.EMAIL_TO,
    subject: `${request.body.name} Contacted You!`,
    text: `
      Name: ${request.body.name}
      E-mail address: ${request.body.email}
      Message: ${request.body.message}
    `
  };
  
  transporter.sendMail(mailOptions, (error, info) => {
      if (error) {
          return response.json({error: true});
      }
      response.json({done: true});
  });

```

The code I’m suing is a modified version of the code found [here](https://nodemailer.com/about/). Perhaps you could try including `console.log('Message sent: %s', info.messageId);` in the `sendMail()` method to see if it helps.

Good luck! 🙂

---

<div class="post-metadata">

**Author:** ![publicalias](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/publicalias/32/52515_2.png) [@publicalias](https://forum.freecodecamp.org/u/publicalias)\
**Post date:** [October 2, 2017, 6:04am UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/4 "2017-10-02T06:04:35Z")

</div>

@JacksonBates

I’ll have to try that. Thank you. I wasn’t really sure what the live chat support was for. It’s encouraging to hear that they deal with this sort of thing.

@honmanyau

Yeah, it’s weird. I connected it to my Gmail account just fine. I think you’re right that the code isn’t the problem–or if it is, it’s some namecheap-specific idiosyncracy. Either way, they should have the answers. Thank you for sharing your experience.

---

<div class="post-metadata">

**Author:** ![PortableStick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/portablestick/32/65591_2.png) [@PortableStick](https://forum.freecodecamp.org/u/PortableStick)\
**Post date:** [October 2, 2017, 10:27pm UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/5 "2017-10-02T22:27:21Z")

</div>

Have you tried setting `secure` to true? Namecheap uses TLS.

---

<div class="post-metadata">

**Author:** ![publicalias](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/publicalias/32/52515_2.png) [@publicalias](https://forum.freecodecamp.org/u/publicalias)\
**Post date:** [October 3, 2017, 5:27am UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/6 "2017-10-03T05:27:45Z")

</div>

@PortableStick

Yes, I’ve tried both values with both ports (587 and 465). Would setting additional [TLS options](https://nodejs.org/api/tls.html#tls_class_tls_tlssocket) help, like `isServer` or `requestCert`? At this point, I’m just throwing code at the wall and seeing what sticks. I used 465 and SSL when I added it to my Gmail account. Can I tell nodemailer to use SSL?

---

<div class="post-metadata">

**Author:** ![PortableStick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/portablestick/32/65591_2.png) [@PortableStick](https://forum.freecodecamp.org/u/PortableStick)\
**Post date:** [October 3, 2017, 2:09pm UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/7 "2017-10-03T14:09:55Z")

</div>

I would try setting `secure` to true and change the port to 465, which is the configuration that makes most sense (@honmanyau and I both use it on our sites). If that doesn’t work, I’d suspect an issue with your username or password. I remember having some trouble getting Nodemailer working with my [gandi.net](http://gandi.net) mailserver because I was trying to log in with just the username rather than the full email address ([user@domain.com](mailto:user@domain.com)). You may want to send a test message to your Namecheap email account to verify that it’s up and running. Failing all of that, Namecheap customer service is your only hope.

Every time I hook up some automated email service on the backend, it either works right away or eats away at my life because of some silly little problem.

---

<div class="post-metadata">

**Author:** ![JacksonBates](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jacksonbates/32/123402_2.png) [@JacksonBates](https://forum.freecodecamp.org/u/JacksonBates)\
**Post date:** [October 3, 2017, 10:40pm UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/8 "2017-10-03T22:40:14Z")

</div>

> [@PortableStick](#):
>
> Every time I hook up some automated email service on the backend, it either works right away or eats away at my life because of some silly little problem.

I suspect this is dev life in a sentence.

---

<div class="post-metadata">

**Author:** ![publicalias](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/publicalias/32/52515_2.png) [@publicalias](https://forum.freecodecamp.org/u/publicalias)\
**Post date:** [October 4, 2017, 5:25am UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/9 "2017-10-04T05:25:27Z")

</div>

I should have mentioned that I’m working on Cloud9. As it turns out, they only allow access to ports 8080, 8081, and 8082. One more reason to use a different IDE.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:54pm UTC](https://forum.freecodecamp.org/t/nodemailer-for-namecheap-private-email/150790/10 "2021-01-16T17:54:20Z")

</div>


