请教有关java mail的问题
zhuq 2004-11-22 03:53:33 try {
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.zhaopin.com");
Session sendMailSession;
Store store;
Transport transport;
sendMailSession = Session.getInstance(props, null);
Message newMessage = new MimeMessage(sendMailSession);
newMessage.setFrom(new InternetAddress("ford.zhu@zhaopin.com"));
// InternetAddress[] address= {new InternetAddress("fordzhuqi@sohu.com")};
//for(int i=0;i<address.length;i++){
// System.out.println("address=============="+address[i].toString());
//}
// newMessage.setRecipients(Message.RecipientType.TO,address);
newMessage.setRecipient(Message.RecipientType.TO,
new InternetAddress("fordzhuqi@sohu.com"));
System.out.println("message================="+new InternetAddress("fordzhuqi@sohu.com"));
newMessage.setSubject("hello");
newMessage.setSentDate(new Date());
newMessage.setText("hahahahahahahaha");
//
Vector file = new Vector();
// file.add("636.jpg");
Enumeration efile = file.elements();
String filename = "";
Multipart mp = new MimeMultipart();
while (efile.hasMoreElements()) {
MimeBodyPart mbp = new MimeBodyPart();
filename = efile.nextElement().toString();
FileDataSource fds = new FileDataSource(filename);
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
}
file.removeAllElements();
newMessage.setContent(mp);
newMessage.setText("asdfasdf");
transport = sendMailSession.getTransport("smtp");
transport.send(newMessage,newMessage.getAllRecipients());
}
catch (MessagingException m) {
m.printStackTrace();
}
结果返回:
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 450 <zpbj418>: Helo command rejected: Host not found
很急 请各位打下指点迷津 感激涕零