그래서 node.js를 통해 내 IP 주소를 보내려고 노력 중이며 지금까지는 손을 들지 않았습니다. 지금까지 내 코드는 다음과 같습니다.node.js를 사용하여 이메일에 IP 주소 보내기
var exec = require("child_process").exec;
var ipAddress = exec("ifconfig | grep -m 1 inet", function (error, stdout, stderr) {
ipAddress = stdout;
});
var email = require('nodemailer');
email.SMTP = {
host: 'smtp.gmail.com',
port: 465,
ssl: true,
user_authentication: true,
user: '[email protected]',
pass: 'mypass'
}
email.send_mail({
sender: '[email protected]',
to: '[email protected]',
subject: 'Testing!',
body: 'IP Address of the machine is ' + ipAddress
},
function(error, success) {
console.log('Message ' + success ? 'sent' : 'failed');
console.log('IP Address is ' + ipAddress);
process.exit();
}
);
지금까지 이메일을 보내지 만 IP 주소를 삽입하지 않습니다. 그것은 볼 수있는 콘솔 로그에 적절한 IP 주소를 넣지 만 전자 메일로 보낼 수는 없습니다. 아무도 내 코드에서 내가 뭘 잘못하고 있는지 알 수 있습니까?
당신이 교차 OS 인 대신 os.networkInterfaces''의 "간부"사용하는 이유는 무엇입니까? 출처 : http://nodejs.org/docs/latest/api/os.html#os_os_networkinterfaces – seppo0010