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