我正在尝试建立一个匿名反馈表,人们可以向我发送反馈。我已经查看了nodemailer和node-sendmail,但是没有发件人地址,它们似乎都无法工作。我知道可以处理php的邮件,但这也可以在node.js上完成吗?
这是表格:
<form action="http://localhost:3000/send_email" method="POST">
<textarea type="text" name="suggestions"></textarea>
</form>
这是我的后端的摘要。邮件进入队列,但从未发送,当我mailq
看到(Deferred: connection refused by [127.0.0.1])
const express = require("express");
const app = express();
app.use(express.urlencoded({extended:true}));
app.use(express.json());
const transport = nodemailer.createTransport({sendmail: true, newline:"unix", debug: true});
app.post("/send_email", function(req,res){
transport.sendMail({
to: "my@email.com",
subject: "Hello World!",
text: `You've got mail! ${req.body.suggestions}`},
function(err, info){
console.log("There was an error!");
}
);
});