admin管理员组文章数量:1323225
This is the my file 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="@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>
This is the my file 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/npm/emailjs-@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>
the error message is this:
{status: 400, text: "The user ID is required. To find this ID, visit https://dashboard.emailjs./admin/integration"}
I created Email Services, Email Templates. I verified my user id many times on (https://dashboard.emailjs./admin/integration).
Share Improve this question asked May 15, 2021 at 9:20 Dima CalmisDima Calmis 1452 gold badges3 silver badges7 bronze badges 1-
emailjs.sendForm(serviceID, templateID, templateParams, userID)
. This seems to be the syntax. You are not passing the 3rd and 4th params correctly. – Nisanth Reddy Commented May 15, 2021 at 10:14
3 Answers
Reset to default 7EmailJS team has rearranged the dashboard design. "Integration" page has been removed from the dashboard. API keys moved to the "Account" page. "User ID" renamed to "Public Key"
I put js code in main.js in this way
emailjs.init("my_user_id");
window.onload = function() {
document.getElementById('contact-form').addEventListener('submit', function(event) {
event.preventDefault();
emailjs.sendForm('my_serves_id', 'my_template_id', this)
.then(function() {
console.log('SUCCESS!');
}, function(error) {
console.log('FAILED...', error);
});
});
}
And now all work.
"User ID" renamed to "Public Key".And it is in Account Page of EmailJs
本文标签:
版权声明:本文标题:javascript - I try to use emailjs, but I have this error "user id is required". How to fix it? - Stack Overflo 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742085275a2419938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论