Nodemailer for Namecheap Private Email

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:

var transporter = nodemailer.createTransport({
  host: "",
  port: 587,
  secure: false,
  auth: {
    user: email,
    pass: password

These are the only resources I’ve found:

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.

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 :slight_smile:

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):

  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: `${} Contacted You!`,
    text: `
      Name: ${}
      E-mail address: ${}
      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. Perhaps you could try including console.log('Message sent: %s', info.messageId); in the sendMail() method to see if it helps.

Good luck! :slight_smile:


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.


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.

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


Yes, I’ve tried both values with both ports (587 and 465). Would setting additional TLS options 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?

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 mailserver because I was trying to log in with just the username rather than the full email address ( 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.

I suspect this is dev life in a sentence.

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.