这是一个非常奇怪的问题,但是我不知道我的应用程序有什么问题。我尚未进行任何更改,但由于某种原因,该应用程序停止发送电子邮件,并显示mask = df1['SME'] == 'Ralph'
我有一个React组件,其中有一个电子邮件字段和一个按钮。单击后,按钮将触发功能:
POST error: cannot find route api/example
ExpressJS路线:
sendMail() {
if (this.state.currentEmail !== "") {
let lastAtPos = this.state.currentEmail.lastIndexOf("@");
let lastDotPos = this.state.currentEmail.lastIndexOf(".");
if (
!(
lastAtPos < lastDotPos &&
lastAtPos > 0 &&
this.state.currentEmail.indexOf("@@") === -1 &&
lastDotPos > 2 &&
this.state.currentEmail.length - lastDotPos > 2
)
) {
this.setState({ error: "Please, provide your real e-mail address!" });
} else {
this.setState({
sending: true,
buttonText: ""
});
let data = {
email: this.state.currentEmail
};
axios
.post("/api/subscribers", data)
.then(res => {
this.setState({ isSent: true }, this.resetForm());
})
.catch(() => {
console.log("Message not sent");
});
}
}
}
就像我说的那样,这在一周前可以正常工作,直到我开始注意到没有发送电子邮件。经过调试,我得到的只是来自客户端的router.post("/", (req, res) => {
let data = req.body;
let smtpTransport = nodemailer.createTransport({
service: "Zoho",
port: 465,
auth: {
user: creds.USER,
pass: creds.PASS
}
});
let mailOptions = {
from: "EMAIL",
to: "EMAIL",
subject: "New user subscribed via DOMAIN",
html: `<p>${data.email}</p>`
};
smtpTransport.sendMail(mailOptions, (error, response) => {
if (error) {
res.send(error);
console.log(error);
} else {
res.send("Success");
}
smtpTransport.close();
});
const msg = {
to: data.email,
from: "DOMAIN <EMAIL>",
templateId: "TEMPLATE ID",
subject: "TEXT",
text: "TEXT"
};
//Send Email
try {
sgMail.send(msg);
} catch (err) {
console.log(err);
}
});
错误和"Message not sent"
路由错误(以及一段HTML代码)。
代码有什么问题?
答案 0 :(得分:0)
这样做的原因是我为Zoho启用了2因素Auth,并且没有收到未成功登录尝试的任何错误!浪费了几个小时才找到原因...