简体   繁体   English

尝试接收电子邮件时出现联系表单问题

[英]Contact form issue when trying to receive emails

When I fill out the text fields and input an email into the text box with the placeholder that says "email", nothing sends to my email after I click submit.当我填写文本字段并在文本框中输入一个 email 并带有“电子邮件”占位符时,单击提交后没有任何内容发送到我的 email。 The only time something does send to my email after I click submit is when I type in my personal email into the "email" textbox.在我单击提交后,唯一一次将某些内容发送到我的 email 是在我将个人 email 键入“电子邮件”文本框时。 My personal email is what recieves anything submitted from this form.我的个人电话 email 负责接收从此表单提交的任何内容。 What am I doing wrong?...我究竟做错了什么?...

I utilized "smtpJS.com" to encrypt and establish securetoken key for smtp through "elasticemail.com" to enable my domain for form submissions to my personal email when someone fills out the form.我使用“smtpJS.com”通过“elasticemail.com”为 smtp 加密和创建 securetoken 密钥,以便在有人填写表格时允许我的域将表格提交到我个人的 email。

JavaScript JavaScript

/*contact form/Send email*/
        /*SmtpJS.com security encryption for host, username, and passowrd*/
 function sendEmail(){
                Email.send({

                SecureToken : "XXXX-XXXX-XXXX-XXXX-XXXX",
                To : 'kalvitzjames1@gmail.com',
                From : document.getElementById("email").value,
                Subject : "New Contact Form Enquiry",
                Body : "<br> Name: " + document.getElementById("name").value
                + "<br> Email: " + document.getElementById("email").value
                + "<br> Phone: " + document.getElementById("phone").value
                + "<br> Message: " + document.getElementById("message").value

                })
                
                .then(message => alert("Thank you for your Message!"));
            }

HTML HTML


<!--SmtpJS.com (for form emails)-->
<script src="https://smtpjs.com/v3/smtp.js"></script>


            <!--calling email function-->
           <form onsubmit="sendEmail(); reset(); return false;">

            
            <h3>Get in touch</h3>
            

            <input type="text" id="name" placeholder="Your Name" required>

            <input type="email" id="email" placeholder="Email" required>

            <input type="text" id="phone" placeholder="phone" required>

            <textarea id="message" rows="4" placeholder="How can I help?"></textarea>

            <button type="submit">Send</button>

           </form>

        </div>
    </div>
    

Link to code on my github链接到我的 github 上的代码

( https://github.com/jameskalvitz/Personal-Website ) ( https://github.com/jameskalvitz/Personal-Website )

Are you trying to make the email look like it would originate from the filler of this form?您是否要使 email 看起来像是来自此表单的填充程序?

Usually email providers forbid to use "arbitrary" email addresses in the from field.通常 email 提供商禁止在from字段中使用“任意”email 地址。 Otherwise you basically would build a spam bot, with which you send emails on behalf of someone else (using their real email addresses but without authentication).否则你基本上会建立一个垃圾邮件机器人,你用它代表其他人发送电子邮件(使用他们真实的 email 地址但没有身份验证)。

If this is a sort of contact form you rather should send from your email address to your email address and populate the reply-to field in the email header for your convenience.如果这是一种联系表格,您宁愿从您的 email 地址发送到您的 email 地址,并在 email header 中填写reply-to字段以方便您使用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM