发送电子邮件至文本“电子邮件”在文本框中
我的 jsp 中有一个文本框,想向收件人发送一封电子邮件,他/她的电子邮件被输入到文本框中。
您能指导我如何做到这一点吗?
我刚刚检查了这段代码:
<html>
<head>
<title>mailto Example</title>
</head>
<body>
<form action="mailto:[email protected]" method="post" enctype="text/plain" >
FirstName:<input type="text" name="FirstName">
Email:<input type="text" name="Email">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
I am having a textbox in my jsp and would like to send an e-mail to the receipent which his/her e-mail is entered in the textbox.
Can you please guide me on how to do that.
I have just checked out this code:
<html>
<head>
<title>mailto Example</title>
</head>
<body>
<form action="mailto:[email protected]" method="post" enctype="text/plain" >
FirstName:<input type="text" name="FirstName">
Email:<input type="text" name="Email">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将表单发布到 servlet,并从 servlet 执行此方法来发送邮件。
你的表单应该是
下面是从java发送电子邮件的代码,在web.xml中为servlet进行正确的映射
有关 servlet 教程,请查看此处
You need to post your form to a servlet and from servlet execute this method to send mail.
your form should be
Here is code to send email from java,do proper mapping for servlet in web.xml
For servlet tutorials check it here
执行此操作的常见方法是使用一些服务器端脚本(例如在 php 中),它将获取表单的值,从中创建电子邮件并发送它。
表单数据当然可以通过 javascript / ajax 发送,但我认为在使用 php 脚本时没有必要。
The common way to do this is to have some server side script, e.g. in php, which will take the form's values, create an email from that and send it.
The form data could of course be sent via javascript / ajax, but that I think would not be necessary when using a php script.