javamail应用中出现的错误,请高手赐教!

zhaoyan310 2001-05-28 01:35:00
<%@ page language="java" import="java.util.*,java.net.*,java.io.*, javax.mail.*, javax.mail.internet.*, javax.activation.*,java.util.*"%>
<%
if(request.getMethod().equals("POST"))
{
if(request.getParameter("sub").equals("发 送"))
{  
Properties props=new Properties();
String mailhost=null;
mailhost="XXX.com.cn"
Session sendMailSession;
Store store;
Transport transport;
sendMailSession=Session.getDefaultInstance(props,null);
props.put("mail.smtp.host",mailhost);
javax.mail.Message newMessage=new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress(request.getParameter("from")));
newMessage.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(request.getParameter("to")));
newMessage.setSubject(request.getParameter("subject"));
newMessage.setSentDate(new java.util.Date());
newMessage.setText(request.getParameter("text"));
transport = sendMailSession.getTransport("smtp");
transport.send(newMessage);

}
}

%>
 
<html>
<head>
</head>
<BODY>
   <FORM action="mail.jsp" method="POST" name="mailform">
   <TABLE align="center">
   <TR>
   <TD width="50%">
    To:<BR><INPUT name="to" size="25">
   </TD>
   <TD width="50%">
    From:<BR><INPUT name="from" size="25">
   </TD>
   </TR>
   <TR>
   <TD colspan="2">
    Subject:<BR><INPUT name="subject" size="50">
   </TD>
   </TR>
   <TR>
   <TD colspan="2">
    <P>Message:<BR><TEXTAREA name="text" rows=25 cols=85></TEXTAREA></P>
   </TD>
   </TR>
   </TABLE>
   <INPUT type="submit" name="sub" value="发 送">
   <INPUT type="reset" name="reset" value="重 填">
  </FORM>
  </BODY>
  </HTML>
运行中出现的错误:
org.apache.jasper.JasperException: Unable to compile class for JSP/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fcartoon_00033_00036_00030_0002ffourcom_0002fmail_0002ejspmail_jsp_1.java:104: Invalid character in input.
  
^
/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fcartoon_00033_00036_00030_0002ffourcom_0002fmail_0002ejspmail_jsp_1.java:104: Invalid character in input.
  
^
/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fcartoon_00033_00036_00030_0002ffourcom_0002fmail_0002ejspmail_jsp_1.java:104: Invalid character in input.
  
^
/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fcartoon_00033_00036_00030_0002ffourcom_0002fmail_0002ejspmail_jsp_1.java:104: Invalid character in input.
对于你的帮助万分感谢!
...全文
50 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhaoyan310 2001-05-29
现在错误变成“No provider for smtp”只有再劳驾各位了
回复
skyyoung 2001-05-28
newMessage.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(request.getParameter("to")));

改成
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(request.getParameter("to"), false));
回复
zhaoyan310 2001-05-28
我已经是在mailhost="XXX.com.cn"设置正确的情况下出的错误!请各位找找其他原因。
回复
mailhost="XXX.com.cn"
这句要修改吧?例如 mailhost="smtp.163.com"
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2001-05-28 01:35
社区公告
暂无公告