简体   繁体   English

发件人 email 地址未包含在 EmailJS 中

[英]Sender email address not included in EmailJS

When I submit the form, I receive the user's message.当我提交表单时,我会收到用户的消息。 However, I don't know who it's from.但是,我不知道它来自谁。 I don't receive their email address, nor their name.我没有收到他们的 email 地址,也没有他们的名字。 I tried looking at their documentation but wasn't able to get past this.我尝试查看他们的文档,但无法克服这一点。 Any help will be appreciated.任何帮助将不胜感激。 Thank you!谢谢!

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/emailjs-com@2/dist/email.min.js"></script>
<script type="text/javascript">
    (function () {
        // https://dashboard.emailjs.com/admin/integration
        emailjs.init("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("MY_SERVICE_ID", "MY_TEMPLATE_ID", 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>

{{message}} is the only thing you can receive from the form for now because your template has two dynamic variables {{from_name}} , {{message}} but you are sending contact_number , user_name , user_email and message which is written in name attributes for each inputs in the form. {{message}}是您现在可以从表单中收到的唯一内容,因为您的模板有两个动态变量{{from_name}}{{message}}但您发送的是contact_numberuser_nameuser_emailmessage表单中每个输入的名称属性。

You have to match names of template variables and names of form inputs.您必须匹配模板变量的名称和表单输入的名称。 If you want to maintain your form, you have to modify your template like如果要维护表单,则必须修改模板,例如

from You got a new email from {{from_name}}: {{message}} You got a new email from {{from_name}}: {{message}}

to You got a new email from {{user_name}}({{user_email}}): {{message}} You got a new email from {{user_name}}({{user_email}}): {{message}}

You can also use built-in variables without getting input but I'll leave them because you need to read the documentation for good.您也可以在不获取输入的情况下使用内置变量,但我将保留它们,因为您需要永久阅读文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 emailjs 发送 email? - How to send an email with emailjs? 使用JavaScript在HTA中发送电子邮件并隐藏发件人的电子邮件地址 - Send email in HTA using JavaScript and hide the sender's email address 电子邮件被回复给收件人而不是发件人或回复地址 - Email being replied to receiver instead of sender or the reply-to address 为什么 emailjs 不向我发送 emailjs? 在 HTML? 如何在 HTML 中使用 emailjs 发送 email? - Why emailjs is not sending me emailjs? in HTML? How can i send email with emailjs in HTML? EmailJS 未发送 email,服务 ID 无效错误 - EmailJS not sending email, Service ID is invalid error 无法在没有警报的情况下使用EmailJS发送电子邮件 - unable to email using EmailJS without alert 使用 EmailJS 直接从 JavaScript 发送 Email - Send Email Directly From JavaScript using EmailJS 如何使用 EmailJS 在特定日期发送 email - How to send email on certain date with EmailJS emailJS POST https://api.emailjs.com/api/v1.0/email/send 400 reactjs - emailJS POST https://api.emailjs.com/api/v1.0/email/send 400 reactjs Google Apps 脚本 - 如何发送带有回复但屏蔽发件人地址的电子邮件? - Google Apps Script - How can I send an email WITH reply-to but MASKING the sender address?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM