[英]I try to use emailjs, but I have this error "user id is required". How to fix it?
This is the my file index.html这是我的文件索引。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>
the error message is this:错误信息是这样的:
{status: 400, text: "The user ID is required. To find this ID, visit https://dashboard.emailjs.com/admin/integration"} {状态:400,文本:“用户 ID 是必需的。要查找此 ID,请访问https://dashboard.emailjs.com/admin/integration”}
I created Email Services, Email Templates.我创建了 Email 服务、Email 模板。 I verified my user id many times on ( https://dashboard.emailjs.com/admin/integration ).
我在( https://dashboard.emailjs.com/admin/integration )上多次验证了我的用户 ID。
EmailJS team has rearranged the dashboard design. EmailJS 团队重新安排了仪表板设计。 "Integration" page has been removed from the dashboard.
“集成”页面已从仪表板中删除。 API keys moved to the "Account" page.
API 键移至“帐户”页面。 "User ID" renamed to "Public Key"
“用户 ID”重命名为“公钥”
I put js code in main.js in this way我是这样把js代码放到main.js中的
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 “用户ID ”重命名为“公钥”。它在EmailJs的帐户页面中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.