我有一个表单,其中包括输入字段和提交按钮。
<form class="subscribe">
<div class="">
<input type="text" placeholder="Your e-mail adresss">
<span>
<button type="button">Subscribe</button>
</span>
</div>
</form>什么是最简单的方式,使这个功能,只使用前端,以便当新的电子邮件被输入,我将收到一封电子邮件与新的注册信息。这可能仅限于JS/Jquery吗?
发布于 2021-08-28 09:25:38
是的,这现在是可能的!您甚至不需要javascript/jquery来实现这一点。
有一个很好的API,您可以使用它发送电子邮件,例如:https://formsubmit.co
您可以阅读文档以获得更多信息。但是这里有一个你可以使用的小片段:
<!--
*Provide your email address on action attribute
*The email you provide on action attribute will be the one to receive an email.
-->
<form action="'https://formsubmit.co/yourEmail@email.com" method="POST">
<input name="email" type="email" required>
<!-- You can add more input/fields, this message input is just to notify you about the subscribers-->
<input hidden name="message" value="Hey! I want to subscribe on your news letter." type="text">
<button type="submit">Subscribe</button>
</form>发布于 2014-02-28 12:33:05
这在前端是不可能的。你必须做这个服务器端。
使用纯javascript的唯一可能是使用预定义的消息来打开用户默认的电子邮件客户端。但是用户仍然需要发送它。
function sendMail() {
var link = "mailto:me@example.com"
+ "?cc=myCCaddress@example.com"
+ "&subject=" + escape("This is my subject")
+ "&body=" + escape(document.getElementById('myText').value)
;
window.location.href = link;
}发布于 2014-02-28 12:26:22
如果您想发送任何邮件,您必须使用服务器端功能,但是javascript/jquery是客户端脚本。
您可以这样做,发出ajax请求并发送所有数据,然后根据需要发送邮件。
https://stackoverflow.com/questions/22095078
复制相似问题