javamail的问题,大家帮忙!

csdn_search 2004-06-10 09:10:54
在9IAS下部署出现奇怪错误!

我用javamail开发的一个发邮件的程序,我的开发工具是jdevw,类似jbuilder,我的发email程序在jdevw自带的oc4j下跑是正常的,可以发出,但是我把程序部署在9ias(版本:9.0.3)上便出现错误,错误如下:
+++++++++++
500 Internal Server Error
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: Unknown SMTP host: xhxx.net;
nested exception is:
java.net.UnknownHostException: xhxx.net
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
at net.xhxx.tis.gzxxw.sendMail_disc.send(sendMail_disc.java:79)
at _gzxxw._p04._p04__dbLeaderEmail._jspService(_p04__dbLeaderEmail.java:106)
[SRC:/gzxxw/p04/p04_dbLeaderEmail.jsp:54]
at com.orionserver[Oracle9iAS (9.0.3.0.0) Containers for J2EE].http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:560)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.AJPRequestHandler.run(AJPRequestHandler.java:148)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.AJPRequestHandler.run(AJPRequestHandler.java:72)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:479)
...全文
105 7 点赞 打赏 收藏 举报
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
tyyang 2004-06-14
等我仔细看看
  • 打赏
  • 举报
回复
haichuang 2004-06-14
请确认服务器的DNS能正常解析xhxx.net
  • 打赏
  • 举报
回复
beming 2004-06-14
错误都已经说出来了:
javax.mail.MessagingException: Unknown SMTP host: xhxx.net;

java.net.UnknownHostException: xhxx.net

xhxx.net连不上,确保网络通畅而且xhxx.net的SMTP服务正常。
  • 打赏
  • 举报
回复
caiyi0903 2004-06-14
smtp服务器地址错误
  • 打赏
  • 举报
回复
CoolAbu 2004-06-14
在你的9ias(版本:9.0.3)上看看能不能ping 通xhxx.net,不行把DNS该一下试试。或者直接用IP,不用域名。
  • 打赏
  • 举报
回复
newfox 2004-06-14
Unknown SMTP host: xhxx.net;

你的SMTP服务器能用吗?

提示出错呀
  • 打赏
  • 举报
回复
csdn_search 2004-06-10
程序如下:
声明:程序上应该没有问题,因为部署在SUN880机器上都没有问题,现在我部署的机器是PC机器,系统:2000server,我在PC上用JDEVW自带的OC4J跑也是正常的,
package net.aa.tis.gzxxw;

import java.util.Date;
import java.util.Hashtable;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.internet.*;
import java.sql.*;
import java.util.ResourceBundle;
import net.aa.tis.common.*;

public class sendMail_disc
{
ResourceBundle bundle=ResourceBundle.getBundle("tis");
String mailhost=bundle.getString("mailhost");
String from=bundle.getString("from");
String user=bundle.getString("user");
String password=bundle.getString("password");

String to;
String subject;
String content;
MimeMessage mimeMsg;
Session session;
String fileAttachment;

public sendMail_disc()
{
/*收信人*/
to = null;
/*主题*/
subject = null;
/*内容*/
content = null;
/*MIME邮件对象 */
mimeMsg = null;
/*邮件会话对象 */
session = null;
/*附件*/
fileAttachment = null;
}

public void setTo(String email)
{
to = email;
}

public void setSubject(String strSubject)
{
subject = strSubject;
}

public void setText(String strContent)
{
content = strContent;
}

public void send()throws Exception
{
java.util.Properties properties = System.getProperties();
properties.put("mail.smtp.host", mailhost);
properties.put("mail.smtp.auth", "true");
session = Session.getInstance(properties, new Email_Autherticatorbean(user, password));
mimeMsg = new MimeMessage(session);
mimeMsg.setFrom(new InternetAddress(from));
if(to != null){
mimeMsg.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
}
mimeMsg.setSubject(subject, "GBK");
MimeBodyPart mimebodypart = new MimeBodyPart();
mimebodypart.setText(content, "GBK");
//MimeBodyPart mimebodypart1 = new MimeBodyPart();
MimeMultipart mimemultipart = new MimeMultipart();

mimemultipart.addBodyPart(mimebodypart);
mimeMsg.setContent(mimemultipart);
mimeMsg.setSentDate(new Date());
Transport.send(mimeMsg);
}
}
  • 打赏
  • 举报
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-06-10 09:10
社区公告
暂无公告