通过 GoDaddy 托管电子邮件使用 Nodemailer 发送电子邮件
Send email using Nodemailer with GoDaddy hosted email
我正在尝试使用 nodemailer
和通过 GoDaddy 配置的自定义电子邮件地址发送电子邮件。这是 c 面板中 "custom configurations" 页面的屏幕截图:
和我的代码:
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 电子邮件发送了一封电子邮件。有没有其他人遇到过这个或对尝试的事情有建议?
你应该对你的运输车做一些改变:
var smtpTrans = nodeMailer.createTransport({
service: 'Godaddy',
host: "smtpout.secureserver.net",
secureConnection: true,
port: 465,
auth: {
user: "username",
pass: "password"
}
});
此错误最常见的问题是防病毒软件。因此,如果您在本地测试它,请将其禁用 10 分钟。
我知道这是一个旧的 post,但由于 GoDaddy SMTP 服务器已更改,我只是想补充一下,以防万一其他人遇到这个问题并遇到我遇到的同样问题。 @tirmey 的回答对我没有用,但是这个对我有用。
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');
}
});
我正在尝试使用 GoDaddy SMTP 设置从 Google Cloud Function 使用 nodemailer 发送电子邮件。我的 GoDaddy 主机上没有启用 Office365。 None 以上选项今天(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);
});
上面提出的解决方案似乎不再有效,none 其中对我有用。以下解决方案对我有用:
const nodemailer = require('nodemailer');
const os = require('os');
let mailerConfig = {
host: os.hostname(),
port: 25,
};
let transporter = nodemailer.createTransport(mailerConfig);
transporter.sendMail({
from: '<from>',
to: '<to>',
subject: '<subject>',
text: '<text>'
}, (err, info) => {
console.log(info);
console.log(err);
});
我正在尝试使用 nodemailer
和通过 GoDaddy 配置的自定义电子邮件地址发送电子邮件。这是 c 面板中 "custom configurations" 页面的屏幕截图:
和我的代码:
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 电子邮件发送了一封电子邮件。有没有其他人遇到过这个或对尝试的事情有建议?
你应该对你的运输车做一些改变:
var smtpTrans = nodeMailer.createTransport({
service: 'Godaddy',
host: "smtpout.secureserver.net",
secureConnection: true,
port: 465,
auth: {
user: "username",
pass: "password"
}
});
此错误最常见的问题是防病毒软件。因此,如果您在本地测试它,请将其禁用 10 分钟。
我知道这是一个旧的 post,但由于 GoDaddy SMTP 服务器已更改,我只是想补充一下,以防万一其他人遇到这个问题并遇到我遇到的同样问题。 @tirmey 的回答对我没有用,但是这个对我有用。
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');
}
});
我正在尝试使用 GoDaddy SMTP 设置从 Google Cloud Function 使用 nodemailer 发送电子邮件。我的 GoDaddy 主机上没有启用 Office365。 None 以上选项今天(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);
});
上面提出的解决方案似乎不再有效,none 其中对我有用。以下解决方案对我有用:
const nodemailer = require('nodemailer');
const os = require('os');
let mailerConfig = {
host: os.hostname(),
port: 25,
};
let transporter = nodemailer.createTransport(mailerConfig);
transporter.sendMail({
from: '<from>',
to: '<to>',
subject: '<subject>',
text: '<text>'
}, (err, info) => {
console.log(info);
console.log(err);
});