我有一个简单的 React 应用程序,我想创建一个表单,将电子邮件发送到特定的 Outlook 地址,而无需添加我自己的后端。
我首先查看了 email.js,这是一个适用于 Gmail 的库,但不适用于我的 Outlook。当我尝试设置正确的电子邮件时,我得到:
412Hotmail:无效登录:535 5.7.139 身份验证不成功,租户禁用了 SmtpClientAuthentication。访问 https://aka.ms/smtp_auth_disabled 了解更多信息。 [MW4PR04CA0143.namprd04.prod.outlook.com]
这导致了一个 powershell 命令的迷宫,由于难以总结的原因,很难遵循并实际使其工作。
然后我尝试使用 https://www.smtpjs.com/,但我无法使其与 React 一起使用。以下代码:
Email.send({
Host : "smtp.yourisp.com",
Username : "username",
Password : "password",
To : 'email@email.com',
From : "you@isp.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);
给出“电子邮件未定义”的错误,无论我在组件中或 index.html 中插入脚本标记的位置都没有关系。我也试过
const script = document.createElement("script");
script.src = "https://smtpjs.com/v3/smtp.js"
在组件内部,还是不行。
目前唯一真正有效的解决方案是 https://formspree.io/,但它是一种低于标准的解决方案,其中发件人被重定向到 Formspree 页面。
我对 SMTP 的理解非常模糊,所以也许我在使用 smtp.js 时犯了一些新手错误。 感谢您的帮助。