- 浏览: 59856 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
ipconfig1:
能不能具体说一下,我在initComponent生成cm还是会 ...
关于Ext可编辑网格第二次不可编辑的问题 -
ipconfig1:
呵呵。谢谢啊,最近也遇到这个问题了。
关于Ext可编辑网格第二次不可编辑的问题 -
xfei6868:
最近也在做这方面,很想知道详细过程,请问能否给详细解释。呵呵! ...
Juddi的配置 -
nforce_com:
...
关于ascii码的转换问题 -
jiaofei3385140:
大哥,我真的要哭了,我按着你的方法看了好几天,终于看好了,准备 ...
硬盘安装ubuntu9.04过程详解
使用Jboss默认的Mail进行邮件发送案例
首先,需要配置mail-service.xml<br><div style="background-color: #eeeeee; font-size: 13px; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%;"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><span style="color: #0000FF;"><?</span><span style="color: #FF00FF;">xml version="1.0" encoding="UTF-8"</span><span style="color: #0000FF;">?></span><span style="color: #000000;"><br></span><span style="color: #008000;"><!--</span><span style="color: #008000;"> $Id: mail-service.xml 62350 2007-04-15 16:50:12Z dimitris@jboss.org $ </span><span style="color: #008000;">--></span><span style="color: #000000;"><br></span><span style="color: #0000FF;"><</span><span style="color: #800000;">server</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> ==================================================================== </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Mail Connection Factory </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> ==================================================================== </span><span style="color: #008000;">--></span><span style="color: #000000;"><br><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">mbean </span><span style="color: #FF0000;">code</span><span style="color: #0000FF;">="org.jboss.mail.MailService"</span><span style="color: #FF0000;"><br> name</span><span style="color: #0000FF;">="jboss:service=Mail"</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">attribute </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="JNDIName"</span><span style="color: #0000FF;">></span><span style="color: #000000;">java:/Mail</span><span style="color: #0000FF;"></</span><span style="color: #800000;">attribute</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">attribute </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="User"</span><span style="color: #0000FF;">></span><span style="color: #000000;">bpm</span><span style="color: #0000FF;"></</span><span style="color: #800000;">attribute</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">attribute </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="Password"</span><span style="color: #0000FF;">>*****</span><span style="color: #0000FF;"></</span><span style="color: #800000;">attribute</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">attribute </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="Configuration"</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> A test configuration </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">configuration</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Change to your mail server prototocol </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.store.protocol"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="pop3"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.transport.protocol"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="smtp"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Change to the user who will receive mail </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.user"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="bpm"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.smtp.auth"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="true"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Change to the mail server </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.pop3.host"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="**pop3服务器地址**"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Change to the SMTP gateway server </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.smtp.host"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="***smtp服务器地址***"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br> <br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> The mail server port </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.smtp.port"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="25"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br> <br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Change to the address mail will be from </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.from"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="bpm@eontime.com.cn"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br><br> </span><span style="color: #008000;"><!--</span><span style="color: #008000;"> Enable debugging output from the javamail classes </span><span style="color: #008000;">--></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">property </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">="mail.debug"</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">="false"</span><span style="color: #0000FF;">/></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">configuration</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">attribute</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"><</span><span style="color: #800000;">depends</span><span style="color: #0000FF;">></span><span style="color: #000000;">jboss:service=Naming</span><span style="color: #0000FF;"></</span><span style="color: #800000;">depends</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br> </span><span style="color: #0000FF;"></</span><span style="color: #800000;">mbean</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br><br></span><span style="color: #0000FF;"></</span><span style="color: #800000;">server</span><span style="color: #0000FF;">></span><span style="color: #000000;"><br></span>
</div>
<br>其次新建一个jsp页面mail2.jsp,作为测试<br><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;"><%</span><span style="color: #000000;">@page contentType</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">text/html</span><span style="color: #000000;">"</span><span style="color: #000000;">%></span><span style="color: #000000;"><br></span><span style="color: #000000;"><%</span><span style="color: #000000;">@ page </span><span style="color: #0000FF;">import</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">javax.mail.*,javax.mail.internet.*, javax.activation.*, javax.naming.InitialContext</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">%></span><span style="color: #000000;"> <br></span><span style="color: #000000;"><</span><span style="color: #000000;">h3</span><span style="color: #000000;">></span><span style="color: #000000;">Test JbsssMail DB</span><span style="color: #000000;"></</span><span style="color: #000000;">h3</span><span style="color: #000000;">></span><span style="color: #000000;"> <br></span><span style="color: #000000;"><%</span><span style="color: #000000;"><br>
String toAddress</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailTo</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
String fromAddress</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailFrom</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
String subject</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailSubject</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
String content</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailContent</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
InitialContext ctx </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> InitialContext(); <br>
Session sessions </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Session) ctx.lookup(</span><span style="color: #000000;">"</span><span style="color: #000000;">java:/Mail</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br></span><span style="color: #0000FF;">if</span><span style="color: #000000;">(toAddress</span><span style="color: #000000;">!=</span><span style="color: #0000FF;">null</span><span style="color: #000000;"> </span><span style="color: #000000;">&&!</span><span style="color: #000000;">toAddress.equals(</span><span style="color: #000000;">""</span><span style="color: #000000;">)){ <br></span><span style="color: #0000FF;">try</span><span style="color: #000000;">{<br>
MimeMessage msg </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MimeMessage(sessions);<br>
msg.setFrom(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> InternetAddress(fromAddress));<br>
msg.setRecipients(javax.mail.Message.RecipientType.TO,toAddress);<br>
msg.setSubject(subject);<br>
msg.setSentDate(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> java.util.Date());<br>
Multipart multipt </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MimeMultipart();<br>
MimeBodyPart msgbody </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MimeBodyPart();<br>
msgbody.setContent(content,</span><span style="color: #000000;">"</span><span style="color: #000000;">text/plain</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
multipt.addBodyPart(msgbody);<br>
msg.setContent(multipt);<br>
Transport.send(msg);<br>
System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">SendMail OK!</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
}</span><span style="color: #0000FF;">catch</span><span style="color: #000000;">(MessagingException e)<br>
{<br>
e.printStackTrace();<br>
}<br>
}<br></span><span style="color: #000000;">%></span><span style="color: #000000;"> <br></span><span style="color: #000000;"><</span><span style="color: #000000;">HTML</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"><</span><span style="color: #000000;">BODY BGCOLOR</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">white</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"><</span><span style="color: #000000;">form METHOD</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">POST</span><span style="color: #000000;">"</span><span style="color: #000000;"> ACTION</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">mail2.jsp</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">table CELLSPACING</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">0</span><span style="color: #000000;">"</span><span style="color: #000000;"> CELLPADDING</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">3</span><span style="color: #000000;">"</span><span style="color: #000000;"> BORDER</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">1</span><span style="color: #000000;">"</span><span style="color: #000000;"> WIDTH</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">474</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">From :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">TEXT</span><span style="color: #000000;">"</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailFrom</span><span style="color: #000000;">"</span><span style="color: #000000;"> value</span><span style="color: #000000;">=</span><span style="color: #000000;">""</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">To :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">TEXT</span><span style="color: #000000;">"</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailTo</span><span style="color: #000000;">"</span><span style="color: #000000;"> value</span><span style="color: #000000;">=</span><span style="color: #000000;">""</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">Subject :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">TEXT</span><span style="color: #000000;">"</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailSubject</span><span style="color: #000000;">"</span><span style="color: #000000;"> value</span><span style="color: #000000;">=</span><span style="color: #000000;">""</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">Content :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">TEXTAREA cols</span><span style="color: #000000;">=</span><span style="color: #000000;">50</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailContent</span><span style="color: #000000;">"</span><span style="color: #000000;"> rows</span><span style="color: #000000;">=</span><span style="color: #000000;">8</span><span style="color: #000000;">></</span><span style="color: #000000;">TEXTAREA</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td colspan</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">2</span><span style="color: #000000;">"</span><span style="color: #000000;"> width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">474</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">Submit</span><span style="color: #000000;">"</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">table</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"></</span><span style="color: #000000;">form</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"></</span><span style="color: #000000;">BODY</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"></</span><span style="color: #000000;">HTML</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span>
</div>
</div>
<br>其次新建一个jsp页面mail2.jsp,作为测试<br><div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #000000;"><%</span><span style="color: #000000;">@page contentType</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">text/html</span><span style="color: #000000;">"</span><span style="color: #000000;">%></span><span style="color: #000000;"><br></span><span style="color: #000000;"><%</span><span style="color: #000000;">@ page </span><span style="color: #0000FF;">import</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">javax.mail.*,javax.mail.internet.*, javax.activation.*, javax.naming.InitialContext</span><span style="color: #000000;">"</span><span style="color: #000000;"> </span><span style="color: #000000;">%></span><span style="color: #000000;"> <br></span><span style="color: #000000;"><</span><span style="color: #000000;">h3</span><span style="color: #000000;">></span><span style="color: #000000;">Test JbsssMail DB</span><span style="color: #000000;"></</span><span style="color: #000000;">h3</span><span style="color: #000000;">></span><span style="color: #000000;"> <br></span><span style="color: #000000;"><%</span><span style="color: #000000;"><br>
String toAddress</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailTo</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
String fromAddress</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailFrom</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
String subject</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailSubject</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
String content</span><span style="color: #000000;">=</span><span style="color: #000000;">request.getParameter(</span><span style="color: #000000;">"</span><span style="color: #000000;">MailContent</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
InitialContext ctx </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> InitialContext(); <br>
Session sessions </span><span style="color: #000000;">=</span><span style="color: #000000;"> (Session) ctx.lookup(</span><span style="color: #000000;">"</span><span style="color: #000000;">java:/Mail</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br></span><span style="color: #0000FF;">if</span><span style="color: #000000;">(toAddress</span><span style="color: #000000;">!=</span><span style="color: #0000FF;">null</span><span style="color: #000000;"> </span><span style="color: #000000;">&&!</span><span style="color: #000000;">toAddress.equals(</span><span style="color: #000000;">""</span><span style="color: #000000;">)){ <br></span><span style="color: #0000FF;">try</span><span style="color: #000000;">{<br>
MimeMessage msg </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MimeMessage(sessions);<br>
msg.setFrom(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> InternetAddress(fromAddress));<br>
msg.setRecipients(javax.mail.Message.RecipientType.TO,toAddress);<br>
msg.setSubject(subject);<br>
msg.setSentDate(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> java.util.Date());<br>
Multipart multipt </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MimeMultipart();<br>
MimeBodyPart msgbody </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MimeBodyPart();<br>
msgbody.setContent(content,</span><span style="color: #000000;">"</span><span style="color: #000000;">text/plain</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
multipt.addBodyPart(msgbody);<br>
msg.setContent(multipt);<br>
Transport.send(msg);<br>
System.out.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">SendMail OK!</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>
}</span><span style="color: #0000FF;">catch</span><span style="color: #000000;">(MessagingException e)<br>
{<br>
e.printStackTrace();<br>
}<br>
}<br></span><span style="color: #000000;">%></span><span style="color: #000000;"> <br></span><span style="color: #000000;"><</span><span style="color: #000000;">HTML</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"><</span><span style="color: #000000;">BODY BGCOLOR</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">white</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"><</span><span style="color: #000000;">form METHOD</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">POST</span><span style="color: #000000;">"</span><span style="color: #000000;"> ACTION</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">mail2.jsp</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">table CELLSPACING</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">0</span><span style="color: #000000;">"</span><span style="color: #000000;"> CELLPADDING</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">3</span><span style="color: #000000;">"</span><span style="color: #000000;"> BORDER</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">1</span><span style="color: #000000;">"</span><span style="color: #000000;"> WIDTH</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">474</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">From :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">TEXT</span><span style="color: #000000;">"</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailFrom</span><span style="color: #000000;">"</span><span style="color: #000000;"> value</span><span style="color: #000000;">=</span><span style="color: #000000;">""</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">To :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">TEXT</span><span style="color: #000000;">"</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailTo</span><span style="color: #000000;">"</span><span style="color: #000000;"> value</span><span style="color: #000000;">=</span><span style="color: #000000;">""</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">Subject :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">TEXT</span><span style="color: #000000;">"</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailSubject</span><span style="color: #000000;">"</span><span style="color: #000000;"> value</span><span style="color: #000000;">=</span><span style="color: #000000;">""</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">150</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">div align</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">left</span><span style="color: #000000;">"</span><span style="color: #000000;">></span><span style="color: #000000;">Content :</span><span style="color: #000000;"></</span><span style="color: #000000;">small</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">324</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">TEXTAREA cols</span><span style="color: #000000;">=</span><span style="color: #000000;">50</span><span style="color: #000000;"> name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">MailContent</span><span style="color: #000000;">"</span><span style="color: #000000;"> rows</span><span style="color: #000000;">=</span><span style="color: #000000;">8</span><span style="color: #000000;">></</span><span style="color: #000000;">TEXTAREA</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"><</span><span style="color: #000000;">td colspan</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">2</span><span style="color: #000000;">"</span><span style="color: #000000;"> width</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">474</span><span style="color: #000000;">"</span><span style="color: #000000;">><</span><span style="color: #000000;">input TYPE</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">Submit</span><span style="color: #000000;">"</span><span style="color: #000000;">></</span><span style="color: #000000;">td</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">tr</span><span style="color: #000000;">></span><span style="color: #000000;"><br>
</span><span style="color: #000000;"></</span><span style="color: #000000;">table</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"></</span><span style="color: #000000;">form</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"></</span><span style="color: #000000;">BODY</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #000000;"></</span><span style="color: #000000;">HTML</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span>
</div>
相关推荐
在JBoss中,我们可以将一个WEB应用配置为默认应用程序,使得用户可以通过IP地址直接访问,而无需在URL中指定具体的工程名。这个过程涉及到对JBoss服务器配置的深入理解和XML文件的编辑。 标题所指的"将WEB应用发布...
"jboss日志发邮件"是指通过配置JBoss来实现日志信息自动发送电子邮件的功能,这在系统监控和故障排查中非常有用。这个过程可能涉及到对特定jar包的替换,以便集成更高级的日志管理和通知机制。以下是关于这个主题的...
jboss oracle 默认配置
默认情况下,JBoss使用特定的端口号进行通信,如8080端口用于HTTP服务,7676端口用于JMX远程管理等。然而,在多服务器环境中,为避免端口冲突,或者出于安全考虑,我们需要修改这些默认端口。标题"修改jboss的默认...
### JBoss 使用详细操作步骤 #### 一、安装与配置 ...通过以上步骤,您可以成功地安装、配置并使用 JBoss,在 MyEclipse 中进行开发和测试工作。掌握 JBoss 的基本操作对于 Java 开发者来说是非常重要的技能之一。
总之,这个"jboss+myeclipse+ejb案例"涵盖了Java EE企业级开发的核心要素,通过学习和实践,开发者可以掌握如何在JBoss环境下使用MyEclipse进行EJB开发,为后续的大型企业级应用开发打下坚实基础。
2.按照里面的文件“邮件发送使用说明”进行简单的修改。 3.把工程放到tomcat/jboss/weblogic/jetty/...或者随便什么服务器里面运行。OK! 还有什么不懂,可以联系我QQ(“邮件发送使用说明”里面有)。
3. 部署管理:可以通过JBOSS管理控制台(默认端口9990)或CLI(Command Line Interface)工具进行远程部署和管理。 四、JBOSS管理控制台 JBOSS提供了一个图形化的管理界面,用户可以在这里查看服务器状态、管理部署...
- server/default目录:JBoss的默认配置,如果没有指定配置名称,会使用此配置。 - server/default/conf目录:默认配置的配置文件。 - server/default/data目录:存储数据库文件,例如嵌入式数据库或JBossMQ数据。 -...
默认情况下,JBoss使用8080端口提供服务。 7. **部署应用**: 将你的Java EE应用程序打包成`.war`或`.ear`文件,然后将其复制到`JBOSS_HOME/standalone/deployments`目录下。JBoss会自动检测并部署该应用。也可以...
jboss esb 实例及讲解,我收集的资料整理做成书
在这个场景中,我们将讨论如何在JBoss环境中使用实体Bean(Entity Bean)及其接口来实现JavaMail邮件的接收。 首先,我们来看实体Bean。实体Bean是持久化的Java对象,它们代表数据库中的记录。在JBoss中,实体Bean...
### JBOSS使用指南知识点详解 #### 一、JBOSS入门 **1. 下载和安装JBoss** - **前提条件**: 在安装JBoss之前,确保计算机已安装了最新的JVM版本。为了运行JBoss 4.2.2GA,开发者需要安装Java 5虚拟机,并确认`...
4. **使用专用的部署目录**:为了避免与默认的`deploy`目录冲突,创建一个新的目录(如`deployments_in_progress`),并将其添加到`jboss-service.xml`的`deployment-scanner`元素中。这样,当在该目录下添加或更新...
官方发布的Jboss解决方案 REDHat公司2010年度最新资料
【JBOSS使用指南】 JBoss是Red Hat公司开发的一款开源的应用服务器,它基于Java EE(Enterprise Edition)标准,提供了一种运行企业级Java应用程序的平台。本指南将深入探讨如何有效利用JBoss进行应用程序部署、...