Dus*_*ler 4 shared-hosting nodemailer
我正在尝试使用nodemailer通过 GoDaddy 配置的自定义电子邮件地址发送电子邮件。这是 c 面板中“自定义配置”页面的屏幕截图:

和我的代码:
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);
}
});
Run Code Online (Sandbox Code Playgroud)
和我的错误日志:
{ 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' }
Run Code Online (Sandbox Code Playgroud)
我尝试更改端口号,使其安全与非 SSL,使用我的网站地址作为主机,以及我能想到的几乎所有其他内容。我已使用其中一个网络邮件客户端成功地从 Godaddy 电子邮件发送了一封电子邮件。有没有其他人遇到过这种情况或对尝试的事情有建议?
Bha*_*wal 19
I am trying to send emails using nodemailer from Google Cloud Function using GoDaddy SMTP settings. I do not have Office365 enabled on my GoDaddy hosting. None of the above options worked for me today (12 November 2019). TLS need to be enabled.
I had to use the following configuration:
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"
}
});
Run Code Online (Sandbox Code Playgroud)
Then, I could send a test email as follows:
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);
});
Run Code Online (Sandbox Code Playgroud)
tir*_*mey 10
你应该对你的运输车做一些改变:
var smtpTrans = nodeMailer.createTransport({
service: 'Godaddy',
host: "smtpout.secureserver.net",
secureConnection: true,
port: 465,
auth: {
user: "username",
pass: "password"
}
});
Run Code Online (Sandbox Code Playgroud)
我意识到这是一篇旧帖子,但只是想补充一下,因为 GoDaddy SMTP 服务器已更改,以防万一其他人遇到此问题并遇到与我相同的问题。@timmey 的答案对我不起作用,但确实如此。
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');
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9397 次 |
| 最近记录: |