这是我的文件index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Form</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/emailjs-com@2/dist/email.min.js"></script>
<script type="text/javascript">
(function() {
(function() {
emailjs.init("here I put my user Id");
})();
</script>
<script type="text/javascript">
window.onload = function() {
document.getElementById('contact-form').addEventListener('submit', function(event) {
event.preventDefault();
// generate a five digit number for the contact_number variable
this.contact_number.value = Math.random() * 100000 | 0;
// these IDs from the previous steps
emailjs.sendForm('contact_service', 'contact_form', this)
.then(function() {
console.log('SUCCESS!');
}, function(error) {
console.log('FAILED...', error);
});
});
}
</script>
</head>
<body>
<form id="contact-form">
<input type="hidden" name="contact_number">
<label>Name</label>
<input type="text" name="user_name">
<label>Email</label>
<input type="email" name="user_email">
<label>Message</label>
<textarea name="message"></textarea>
<input type="submit" value="Send">
</form>
</body>
</html>
错误信息是这样的:
{status: 400, text: "需要用户 ID。要查找此 ID,请访问 https://dashboard.emailjs.com/admin/integration"}
我创建了电子邮件服务、电子邮件模板。 我在 ( https://dashboard.emailjs.com/admin/integration ) 上多次验证了我的用户 ID。
最佳答案
EmailJS 团队重新安排了仪表板设计。 “集成”页面已从仪表板中删除。 API key 移至“帐户”页面。 “用户 ID”重命名为“公钥”
关于javascript - 我尝试使用 emailjs,但出现此错误 "user id is required"。如何修复它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67545172/