简体   繁体   English

我尝试使用 emailjs,但出现此错误“需要用户 ID”。 如何解决?

[英]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.

相关问题 当我尝试使用 emailjs 时出现 thsi 错误:Uncaught ReferenceError: sendMail is not defined emailjs - im getting thsi error when i try to use emailjs: Uncaught ReferenceError: sendMail is not defined emailjs 我将如何在用户点击提交后清除 EmailJS 表单? - How would i clear an EmailJS form after the user hits submit? 为什么 emailjs 不向我发送 emailjs? 在 HTML? 如何在 HTML 中使用 emailjs 发送 email? - Why emailjs is not sending me emailjs? in HTML? How can i send email with emailjs in HTML? 如何在没有 try/catch 块的情况下使用异步 lambda 并且仍然有自定义错误消息? - How can I use async lambdas without a try/catch block and still have custom error messages? 我在尝试使用 props 时遇到了 typeript 错误,有没有办法解决这个问题? - I'm getting a typesript error when I try to use props, is there a way to fix this? 如何让 emailjs 返回成功消息? - How can I get emailjs to return a success message? EmailJS 未发送 email,服务 ID 无效错误 - EmailJS not sending email, Service ID is invalid error 我的网站上有一个关键的监听器,当我尝试输入我的捷径时,我怎么能解决这个问题 - I have a key listener on my website and when i try to input something my short cuts pop open how can i fix this 当我尝试在反应中使用 useReducer 钩子时遇到问题 - i have a problem when i try to use useReducer hooks in react 当我有用户ID时,如何设置用户的语音通道? - How do I set a user's voice channel when I have the user's id?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM