You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用EmailJS时Service ID与Template ID报错问题排查求助

EmailJS使用故障排查求助

问题经过

我正在测试EmailJS库,完全按照官方文档操作:

  • 最初将代码放在contact.html头部的<script>标签中,提交表单时控制台弹出“unexpected”错误
  • 随后创建sendEmail.js文件并关联到contact.html,又出现Service ID不正确的提示
  • 更新Service ID后,又提示Template ID错误,再次更新保存后问题仍未解决

我的EmailJS账号信息

  • Service ID:service_golcdlt(对应截图内容)
  • Template ID:template_7qaoafp(对应截图内容)

相关代码

contact.html初始化代码

<script type="text/javascript">
    (function() {
        emailjs.init("user_vanqZMkpPOADQP2iEpqKS");
    })();
</script>

表单代码

<form onsubmit="return sendMail(this);">
    <input type="text" name="name" class="form-control" id="fullname" placeholder="Name" required/>
    <input type="text" name="emailaddress" class="form-control" id="emailaddress" placeholder="Email" required/>
    <textarea rows="5" name="projectsummary" class="form-control" id="projectsummary" placeholder="Project Description" required></textarea>
    <button type="submit" class="btn btn-secondary center-block">Send Project Request</button>
</form>

sendEmail.js代码

// function has one argument "contactForm"

function sendMail(contactForm) {

const templateParams = {
    "from_name": contactForm.name.value,
    "project_request": contactForm.projectsummary.value,
    "from_email": contactForm.emailaddress.value
};

const serviceID = "service_golcdlt";
const templateID = "template_7qaoafp";

// Service ID, Template ID, template parameters
emailjs.send(serviceID, templateID, templateParams)
    .then(
        function(response) {
            console.log("SUCCESS", response)
        },
        function(error) {
            console.log("Error: Unable to send", error)
        }
    );

    return false; // To block from loading a new page
};

求助

请问我遗漏了什么步骤,或是哪里操作出错了?


内容的提问来源于stack exchange,提问作者TrevTheDev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 08:06:29