发送到电子邮件的联系回复
Posted
技术标签:
【中文标题】发送到电子邮件的联系回复【英文标题】:Contact responses sent to email 【发布时间】:2021-09-25 09:14:33 【问题描述】:我正在使用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,并且每当用户点击提交按钮时,响应都会发送到电子邮件?任何建议都会有很大帮助。我尝试更改它,但卡住了。
【问题讨论】:
这能回答你的问题吗? Sending emails in Node.js? 【参考方案1】:您可以下载 xampp 包 (windows/linux) 并启动 apache 服务器,这样您就可以无缝地运行您的 PHP 脚本。
这里是下载链接:https://www.apachefriends.org/download.html
如果您是 Linux,也可以下载。
【讨论】:
以上是关于发送到电子邮件的联系回复的主要内容,如果未能解决你的问题,请参考以下文章