shared-hosting - 使用 Nodemailer 和 GoDaddy 托管电子邮件发送电子邮件

标签 shared-hosting nodemailer

我正在尝试使用 nodemailer 发送电子邮件以及通过 GoDaddy 配置的自定义电子邮件地址。这是 c 面板中“自定义配置”页面的屏幕截图:
enter image description here

和我的代码:

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 电子邮件发送了一封电子邮件。有没有其他人遇到过这种情况或对尝试的事情有建议?

最佳答案

我正在尝试使用 GoDaddy SMTP 设置从 Google Cloud Function 使用 nodemailer 发送电子邮件。我的 GoDaddy 主机上没有启用 Office365。今天(2019 年 11 月 12 日),上述选项都不适合我。需要启用 TLS。

我不得不使用以下配置:

const mailTransport = nodemailer.createTransport({    
    host: "smtpout.secureserver.net",  
    secure: true,
    secureConnection: false, // TLS requires secureConnection to be false
    tls: {
        ciphers:'SSLv3'
    },
    requireTLS:true,
    port: 465,
    debug: true,
    auth: {
        user: "put your godaddy hosted email here",
        pass: "put your email password here" 
    }
});

然后,我可以发送一封测试电子邮件,如下所示:
const mailOptions = {
            from: `put your godaddy hosted email here`,
            to: `bharat.biswal@gmail.com`,
            subject: `This is a Test Subject`,
            text: `Hi Bharat    

            Happy Halloween!

            If you need any help, please contact us.
            Thank You. And Welcome!

            Support Team
            `,

        };

mailTransport.sendMail(mailOptions).then(() => {
            console.log('Email sent successfully');
        }).catch((err) => {
            console.log('Failed to send email');
            console.error(err);
        });

关于shared-hosting - 使用 Nodemailer 和 GoDaddy 托管电子邮件发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44853483/

相关文章:

php - 在也是子域的共享主机上运行 Zend Framework 应用程序

node.js - NodeJS - 使用 nodemailer-smtp-transport 的 nodemailer

node.js - 无法找到安全性较低的应用程序设置

Node.js plesk - 使用 nodemailer 发送电子邮件不起作用

php - 1and1 托管 : Data migration from shared hosting to VPS

php - zend 和 htaccess 的问题

php - 共享主机安全吗?

PHP 奇怪的 DOCUMENT_ROOT

javascript - Nodejs Node 邮件程序错误

javascript - 使用 Sendgrid/Nodemailer 将 Angular 表单数据发布到 Node.js