- 確かに、それはサーバーの構成に完全に依存します。認証を使用しない限り、ほとんどの電子メール サーバーは機能しません。2017年です
- さて、AFAIK nodemailer は、電子メール ドメインに基づいて正しい構成を検出します。この例では、トランスポーター オブジェクトを設定していないため、構成されているデフォルトのポート 25 を使用します。ポートを変更するには、オプションでタイプを指定します。そして、明示的に指定することを強くお勧めします。
- おそらく、Windows ファイアウォールまたはアンチウイルスが発信アクセスを妨げています。デバッグ/エラー メッセージを取得してみてください。あなたをもっと助ける何かが必要です。
以下は nodemailer の新しいバージョンで、使用方法の例を次に示します。
const nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: 'smtp.example.com',
port: 465,
secure: true, // secure:true for port 465, secure:false for port 587
auth: {
user: 'username@example.com',
pass: 'userpass'
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"Fred Foo " <foo@blurdybloop.com>', // sender address
to: 'bar@blurdybloop.com, baz@blurdybloop.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ?', // plain text body
html: '<b>Hello world ?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
お役に立てば幸いです。