java代码:
---------------------------------------------------------------------------------------
package com.lizongbo;
import java.util.*;
import javax.mail.internet.*;
import javax.mail.*;
/**
*
Title: javamail to 163
*
*
Description: 用javamail免认证方式发送邮件给163.com的用户,
* 具体原理不在此作详细解说,有兴趣者请自行查阅相关资料。
* /p>
*
*
Copyright: Copyright (c) 2005
*
*
Company: lizongbo
*
* @author lizongbo http://www.donews.net/lizongbo
* @version 1.0
*/
public class JavaMail163 {
public static void main(String[] args) throws AddressException,
MessagingException {
Properties mailpro = new Properties();
mailpro.setProperty("mail.smtp.host", "202.108.44.210");
Session session = Session.getDefaultInstance(mailpro);
session.setDebug(true);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("
[email protected]"));
msg.setRecipient(Message.RecipientType.TO,
new InternetAddress("
[email protected]"));
msg.setSubject("测试免认证方式发送邮件!!!");
msg.setText("测试一下,邮件来自 http://www.donews.net/lizongbo ");
Transport.send(msg);
}
}
---------------------------------------------------------------------------------------
执行结果:
---------------------------------------------------------------------------------------
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG: SMTPTransport trying to connect to host "202.108.44.210", port 25
DEBUG SMTP RCVD: 220 Coremail SMTP(Anti Spam) System (163com[20050206])