import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMail {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
// props.setProperty("mail.debug", "true");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.transport.protocol", "smtp");
Session session = Session.getInstance(props);
session.setDebug(true);
Message msg = new MimeMessage(session);
msg.setText("您好啊!");
msg.setFrom(new InternetAddress("
[email protected]"));
Transport transport = session.getTransport();
transport.connect("smtp.sina.com", 25, "zlqfjhome", "fujin830925");
transport.sendMessage(msg, new Address[] { new InternetAddress(
"
[email protected]") });
transport.close();
}
}