欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

邮件发送简单例子-jsp文件

程序员文章站 2023-12-18 21:24:22
mailexample.jspjsp javamail example </title>...</div> <div class="content"> mailexample.jsp<br><br><html><br><head><br><title>jsp javamail example </title><br></head><br><br><body><br><br><%@ page import="java.util.*" %><br><%@ page import="javax.mail.*" %><br><%@ page import="javax.mail.internet.*" %><br><%@ page import="javax.activation.*" %><br><br><%<br>string host = "yourmailhost";<br>string to = request.getparameter("to");<br>string from = request.getparameter("from");<br>string subject = request.getparameter("subject");<br>string messagetext = request.getparameter("body");<br>boolean sessiondebug = false;<br><br>// create some properties and get the default session.<br>properties props = system.getproperties();<br>props.put("mail.host", host);<br>props.put("mail.transport.protocol", "smtp");<br><br>session mailsession = session.getdefaultinstance(props, null);<br><br>// set debug on the session so we can see what is going on<br>// passing false will not echo debug info, and passing true<br>// will.<br>mailsession.setdebug(sessiondebug);<br><br>// instantiate a new mimemessage and fill it with the<br>// required information.<br>message msg = new mimemessage(mailsession);<br><br>msg.setfrom(new internetaddress(from));<br>internetaddress[] address = {new internetaddress(to)};<br>msg.setrecipients(message.recipienttype.to, address);<br>msg.setsubject(subject);<br>msg.setsentdate(new date());<br>msg.settext(messagetext);<br><br>// hand the message to the default transport service<br>// for delivery.<br>transport.send(msg);<br><br>out.println("mail was sent to " + to);<br>out.println(" from " + from);<br>out.println(" using host " + host + ".");<br><br>%><br></table><br></body><br></html><br><br> </div> <div class="info-pre-next"> <p> 上一篇: <a href="/article/.html"> </a> </p> <p> 下一篇: <a href="/article/.html"> </a> </p> </div> <div class="wz_tuijian"> <p> 推荐阅读 </p> <ul> <li> <a href="/article/2278970.html" target="_blank" title="邮件发送简单例子-bean文件"> <h2> 邮件发送简单例子-bean文件 </h2> </a> </li> <li> <a href="/article/2278975.html" target="_blank" title="邮件发送简单例子-jsp文件"> <h2> 邮件发送简单例子-jsp文件 </h2> </a> </li> <li> <a href="/article/2278957.html" target="_blank" title="邮件发送简单例子-html文件"> <h2> 邮件发送简单例子-html文件 </h2> </a> </li> <li> <a href="/article/2270024.html" target="_blank" title="JSP发送邮件实例"> <h2> JSP发送邮件实例 </h2> </a> </li> <li> <a href="/article/2256701.html" target="_blank" title="Python实现的简单发送邮件脚本分享"> <h2> Python实现的简单发送邮件脚本分享 </h2> </a> </li> <li> <a href="/article/2172232.html" target="_blank" title="Python实现的简单发送邮件脚本分享"> <h2> Python实现的简单发送邮件脚本分享 </h2> </a> </li> <li> <a href="/article/2158542.html" target="_blank" title="PHP实现简单的发送HTML邮件"> <h2> PHP实现简单的发送HTML邮件 </h2> </a> </li> <li> <a href="/article/2155456.html" target="_blank" title="PHP循环输出指定目录下的所有文件和文件夹路径例子(简单实用)"> <h2> PHP循环输出指定目录下的所有文件和文件夹路径例子(简单实用) </h2> </a> </li> <li> <a href="/article/2155275.html" target="_blank" title="python实现定时压缩指定文件夹发送邮件"> <h2> python实现定时压缩指定文件夹发送邮件 </h2> </a> </li> <li> <a href="/article/2146922.html" target="_blank" title="Shell脚本实现自动发送邮件的例子"> <h2> Shell脚本实现自动发送邮件的例子 </h2> </a> </li> </ul> </div> </article> </div> </main> <footer><div class="box"><div class="ft_nav"><div class="ft_about"><p>关于网站</p><ul><li><a href="/sitemap.xml" target="_blank" title="网站地图">网站地图</a></li><li><a href="/list/2/" title="最新程序员文章站">最新程序员文章站</a></li></ul></div><div class="ft_contact"><ul><li>本站所有数据收集于网络如有侵犯到您的权益,请联系我们进行下架处理。</li><li class="email_show"></li></ul></div></div><div class="copyright"><div class="cr_left"><p> 备案号:<a href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank">粤ICP备20058927号</a></p><p>© Copyright © 2020-2022 www.superweb999.com 程序员文章站. </p></div></div></div></footer> </body> </html>