我在本社区下了个JAVAMAIL的源代码 但是就是怎么改都无法发送邮件 ,请各位大侠指点迷津 谢谢
代码如下
package com.loyin.util;import java.util.Properties;import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.activation.DataHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.activation.DataSource;
import java.net.URL;/**
 * @(#)MailExample.java Copyright(c) 2004-2005, RenMai Tech.Co.,Ltd. All Rights
 *                      Reserved.
 * 
 * @author wang.li
 * @version 1.0 History: <author> <time> <version> <desc> wang.li 2005-12-21 1.0
 *          create,modify
 */
public class Jmail {
public static void main(String args[]) throws Exception, MessagingException {
String host = "smtp.163.com";// 发件服务器地址
String from = "[email protected]";// 发送方
String pass="****";//密码 不方便公布 见谅 ^_^
String  to= "[email protected]";// 接收方

// 设置java mail属性
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);// 设置SMTP发件服务器地址
// props.put("mail.smtp.auth", "false");// 邮件服务器是否要验证
// props.put("mail.smtp.Ehlo", "false");
props.put("mail.transport.protocol","smtp"); 
// Get session
Session session = Session.getDefaultInstance(props, null);// 获取邮件会话
session.setDebug(true);
// Define message
MimeMessage message = new MimeMessage(session);// 消息,相当于一张白纸 // 写信封
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); // 邮件标题
message.setSubject("推荐人才,来自人脉招聘<www.tom.com>"); final String resumeURL = "http://www.tom.com";
// message.setDataHandler(new DataHandler(new DataSource() {
// public InputStream getInputStream() throws java.io.IOException {
// return (new URL(resumeURL)).openStream();
// }
//
// public OutputStream getOutputStream() throws java.io.IOException {
// throw new IOException("it does not support this method now!");
// }
//
// public java.lang.String getContentType() {
// return "text/html";
// }
//
// public java.lang.String getName() {
// return "tom";
// }
// }));
message.saveChanges(); // Send message
Transport transport = session.getTransport("smtp");
transport.connect("mail."+from.substring(from.indexOf("@")+1, from.length())//,808 //端口
,from.substring(0,from.indexOf("@")),pass);
transport.sendMessage(message, message.getAllRecipients());

transport.close();
}
}