邮件发送问题(显示: javax.mail.MessagingException: 561 Access deny for abc@pchome.com.tw)

panzhiwei 2004-10-19 02:16:01
问题如题显示,请高手指教!在线等待!
...全文
107 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
panzhiwei 2004-10-19
还是出现一样的错误,
不知道为什么,有时候能发,有时候就不能发了!
回复
上海老猫 2004-10-19
到底是哪一句出错?再加句props.put("mail.smtp.user",username);
props.put("mail.smtp.password",password);看看
回复
panzhiwei 2004-10-19
还是不行的,改过后又出现如下错误:
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 550 Access deny for pan1024min2088@yahoo
.com.cn
回复
上海老猫 2004-10-19
props.put("mail.host",mailserver);
改为
props.put("mail.smtp.host",mailserver);
回复
panzhiwei 2004-10-19
发送邮件代码如下:
<%@ page import="javax.mail.*"%>
<%@ page import="javax.mail.internet.*"%>
<%@ page import="javax.activation.*"%>
<%@ page import="java.util.*,java.io.*"%>
<html>
<head></head>
<title>
</title>
<body>
<%
InternetAddress[] address=null;
request.setCharacterEncoding("GB2312");
String mailserver="ecd.pchome.com.tw";
String From=request.getParameter("From");
String to=request.getParameter("to");
String title=request.getParameter("title");
String message=request.getParameter("message");
boolean sessionDebug=false;
try{
java.util.Properties props=System.getProperties();
props.put("mail.host",mailserver);
props.put("mail.transport.protocol","smtp");
javax.mail.Session mailsession=javax.mail.Session.getDefaultInstance(props,null);
mailsession.setDebug(sessionDebug);
Message msg=new MimeMessage(mailsession);
msg.setFrom(new InternetAddress(From));
address=InternetAddress.parse(to,false);
msg.setRecipients(Message.RecipientType.TO,address);
msg.setSubject(title);
msg.setSentDate(new Date());
msg.setText(message);
Transport.send(msg);
out.println("email send success!");
}
catch(MessagingException mex)
{
mex.printStackTrace();
}
%>

</body></html>
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告