使用 Nodemailer 和 GoDaddy 托管电子邮件发送电子邮件 [英] Send email using Nodemailer with GoDaddy hosted email

查看:78
本文介绍了使用 Nodemailer 和 GoDaddy 托管电子邮件发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 nodemailer 和通过 GoDaddy 配置的自定义电子邮件地址发送电子邮件.这是 c 面板中自定义配置"页面的屏幕截图:

I am trying to send an email using nodemailer and a custom email address configured through GoDaddy. Here is a screen shot of the "custom configurations" page in c-panel:

和我的代码:

const nodemailer = require('nodemailer');

var transporter = nodemailer.createTransport({
  service: 'Godaddy',
  secureConnection: false,
  auth: {
    user: 'info@mywebsite.com',
    pass: 'mypassword'
  }
});

var mailOptions = {
  from: 'info@mywebsite.com',
  to: 'otheremail@gmail.com',
  subject: 'Sending Email using Node.js',
  text: 'That was easy!',
  html: '<h1>Welcome</h1><p>That was easy!</p>'
};

transporter.sendMail(mailOptions, function(error, info){
  if (error) {
    console.log(error);
  } else {
    console.log('Email sent: ' + info.response);
  }
});

和我的错误日志:

{ Error: connect EHOSTUNREACH 173.201.192.101:25
    at Object.exports._errnoException (util.js:1012:11)
    at exports._exceptionWithHostPort (util.js:1035:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
    code: 'ECONNECTION',
    errno: 'EHOSTUNREACH',
    syscall: 'connect',
    address: '173.201.192.101',
    port: 25,
    command: 'CONN' }

我尝试更改端口号,使其安全与非 ssl 相比,使用我的网站地址作为主机,以及我能想到的几乎所有其他内容.我已使用其中一个网络邮件客户端成功地从 Godaddy 电子邮件发送了一封电子邮件.有没有其他人遇到过这种情况或对尝试的事情有建议?

I've tried changing the port number, making it secure vs non-ssl, using my website address as the host, and pretty much everything else I can think of. I have successfully sent an email from the godaddy email using one of the webmail clients. Has anyone else ever encountered this or have recommendations on things to try?

推荐答案

我意识到这是一个旧帖子,但我想补充一下,因为 GoDaddy SMTP 服务器已更改,以防其他人遇到此问题并我遇到了同样的问题.@timmey 的回答对我不起作用,但确实如此.

I realize this is an old post, but just wanted to add to this since the GoDaddy SMTP server has changed, just in case someone else comes across this and has the same problem I had. The answer by @tirmey did not work for me, but this did.

let nodemailer = require('nodemailer');

let mailerConfig = {    
    host: "smtp.office365.com",  
    secureConnection: true,
    port: 587,
    auth: {
        user: "username@email.com",
        pass: "password"
    }
};
let transporter = nodemailer.createTransport(mailerConfig);

let mailOptions = {
    from: mailerConfig.auth.user,
    to: 'SomePerson@email.com',
    subject: 'Some Subject',
    html: `<body>` +
        `<p>Hey Dude</p>` +
        `</body>`
};

transporter.sendMail(mailOptions, function (error) {
    if (error) {
        console.log('error:', error);
    } else {
        console.log('good');
    }
});

这篇关于使用 Nodemailer 和 GoDaddy 托管电子邮件发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆