繁体   English   中英

联系回复发送到电子邮件

[英]Contact responses sent to email

我正在使用repl.it来构建我的网站,但是, repl.it有一个名为 HTML/CSS/JS 的服务器,它不支持主要用于向电子邮件提交联系响应的 PHP。 该网站建立在 HTML/CSS/JS 服务器中。 所以我不能使用 PHP 向电子邮件提交联系回复。 有没有其他方法可以用 Node.js 做到这一点?

我仍然设置了 PHP,但如果可能的话,只需将其转换为 Node.js。

PHP文件:

$fname = $_POST['firstname'];
$lname = $_POST['lastname'];
$email_address = $_POST['email'];
$message = $_POST['subject'];
if(empty($fname) || 
empty($lname) || 
empty($email_address) || 
empty($message)){
    $errors .= "\n Error: all fields are required";
}else{
//some other code 
$to = $myemail;
$email_subject = "Contact form submission:" . $name;
$email_body = "You have received a new message. ".
" Here are the details:\n Name: " . $name . "\n ".
"Email: $email_address\n Message \n " . $message;
$headers = "From:" . $myemail . "\n";
$headers .= "Reply-To:" . $email_address;
mail($to,$email_subject,$email_body,$headers);

header('Location: thank-you.html');
}

代码的其余部分:

 input[type=text], [type=email], select, textarea { width: 100%; padding: 12px; border: 1px solid #ccc; margin-top: 6px; margin-bottom: 16px; resize: vertical; } input[type=submit] { background-color: rgb(62, 3, 179); color: white; padding: 12px 20px; border: none; cursor: pointer; } input[type=submit]:hover { background-color: deeppink; } .contactform { position: relative; border-radius: 50px; background-color: #f2f2f2; padding: 5px; z-index: 2; display: block; margin-left: auto; margin-right: auto; margin-bottom: auto; margin-top: 1%; width: 100%; animation-name: gradient; animation-duration: 3s; animation-iteration-count: infinite; } .contactform:hover { animation-name: gradient; animation-duration: 15s; animation-iteration-count: infinite; } .column { float: center; width: 50%; margin-top: 6px; padding: 20px; display: block; margin-left: auto; margin-right: auto; width: 40%; } .row:after { content: ""; display: table; clear: both; } @media screen and (max-width: 600px) { .column, input[type=submit] { width: auto; margin-top: 0; } }
 <section id="contact"> <div class="container" data-aos="fade-up"> <div class="contactform"> <div style="text-align:center"> <div class="section-title"> <h2><br/>Get In Touch</h2> </div> <p>Feel Free To Reach Out To Me Through This Form! </p> </div> <div class="row"> <div class="column"> <form name="myform" action="contact.php" method="POST"> <label for="firstname">First Name</label> <input type="text" id="firstname" name="firstname" placeholder="Your name.." required> <label for="lastname">Last Name</label> <input type="text" id="lastname" name="lastname" placeholder="Your last name.." required> <label for="email">Email:</label> <input type="email" id="email" name="email" placeholder="Your Email.." required> <label for="subject">Subject</label> <textarea id="subject" name="subject" placeholder="Lets Collaborate..." style="height:170px" required></textarea> <input type="submit" value="Submit"> </form> </div> </div> </div> </div> </section>

有没有办法将 PHP 代码转换为 Javascript,并且每当用户点击提交按钮时,响应都会发送到电子邮件? 任何建议都会有很大帮助。 我试图改变它,但我被卡住了。

您可以下载 xampp 包 (windows/linux) 并启动 apache 服务器,这样您就可以无缝地运行您的 PHP 脚本。

这是下载链接: https : //www.apachefriends.org/download.html

如果您使用的是 Linux,它也可以下载。

暂无
暂无

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

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