作者kheric (原来我一直在逞强)
看板java
标题[问题] javamail问题
时间Tue Mar 2 17:43:18 2010
小弟 程式码如下
InternetAddress[] address = null ;
final String charset="big5";
String mailserver = "mail.gameflier.com.tw";
String From = "
[email protected]";
String to = Email;
String Subject = "TEST";
String messageText = "TEST";
String name = Friend;
final String UserName="Acc";
final String password="password";
boolean sessionDebug = false;
try {
sun.misc.BASE64Encoder enc = new sun.misc.BASE64Encoder();
// 设定所要用的Mail 伺服器和所使用的传送协定
java.util.Properties props = System.getProperties();
props.put("mail.host",mailserver);
props.put("mail.transport.protocol","smtp");
Authenticator auth = new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication(UserName, password);
}
};
// 产生新的Session 服务
javax.mail.Session mailSession =
javax.mail.Session.getDefaultInstance(props,auth);
mailSession.setDebug(sessionDebug);
Message msg = new MimeMessage(mailSession);
// 设定传送邮件的发信人
InternetAddress ia = new InternetAddress(From);
ia.setPersonal(name, "Big5");
msg.setFrom(ia);
// 设定传送邮件至收信人的信箱
address = InternetAddress.parse(to,false);
msg.setRecipients(Message.RecipientType.TO, address);
// 设定信中的主题
msg.setSubject("=?Big5?B?"+enc.encode(Subject.getBytes())+"?=");
// 设定送信的时间
msg.setSentDate(new Date());
// 设定传送信的MIME Type
msg.setText(messageText);
// 送信
Transport trans = mailSession.getTransport("smtp");
trans.connect(mailserver , UserName , password);
trans.send(msg , msg.getAllRecipients());
trans.close();
System.out.println("邮件己顺利传送");
}
catch (MessagingException mex) {
mex.printStackTrace();
}
执行後,却会出现错误~
com.sun.mail.smtp.SMTPSendFailedException: 554 5.7.1 Rejected:
your IP address is listed in the zen.spamhaus.org RBL
想请问这边的大大们,这个错误讯息是什麽意思~
或者是说 我的程式哪里有错误~~
谢谢~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.166.50.89
1F:推 bala045:你的IP被加到黑名单啦? 03/02 18:33
2F:→ kheric:应该不会吧~~@@||| 03/02 18:50
3F:→ tcw026:确实是如此.spamhaus会把某些ISP的IP加到block list里, 03/05 12:32
4F:推 tcw026:或是你的收件者中,有人complain.你可以去申请de-listing. 03/05 12:35
5F:→ tcw026:这跟程式没有关系,这是跟smtp通话中间回传的错误讯息.ehlo 03/05 12:41