Properties aProperties = System.getProperties();
aProperties.put("mail.transport.protocol","smtp");
aProperties.put("mail.smtp.host","smtp.xxx.com");
pros.put("mail.smtp.port", "8025");
Session session = Session.getInstance(aProperties,null); MimeMessage message = new MimeMessage(session);
aProperties.put("mail.transport.protocol","smtp");
aProperties.put("mail.smtp.host","smtp.xxx.com");
pros.put("mail.smtp.port", "8025");
Session session = Session.getInstance(aProperties,null); MimeMessage message = new MimeMessage(session);
解决方案 »
- 员工管理系统
- java.sql.SQLException: Network error IOException: Address already in use: connect
- 关于session的两个接口??
- 请问该怎样解决这样的排名问题?
- 在服务器下创建文件的问题
- 用B/S编程的几点困惑!
- 兄弟们,知道的给点提示吧!100分相送哦。
- 我装了Tomcat4.1.24和Apache2.0.48,现在我想装一个IIS,怎么配置?
- JSP调用数据库连接时候的加法
- 请问:response.sendRedirect() 与request.getRequestDispatcher("").forward()的详细区别是什么
- store.getFolder("INBOX");//收邮件,这里除了INBOX外,还有哪些设置,最好讲讲原理?
- 谁能介绍几本关于JSP的好书!
aProperties.put("mail.transport.protocol","smtp");
aProperties.put("mail.smtp.host","smtp.xxx.com");
aProperties.put("mail.smtp.port", "9025");
Session session = Session.getInstance(aProperties,null); MimeMessage message = new MimeMessage(session);
<%
Properties props = new Properties();
props.put("mail.smtp.host","192.168.199.3");
Session s = Session.getInstance(props,null);// Store store = s.getStore("pop3");
int port = 8110;
String username = "yourname#pop.21cn.com";
String password = "******";
String server = "192.168.199.1";
String protocol = "pop3";
String file = "C:/home/mail/999/Maildir/rev";
s.setDebug(false);
URLName urln = new URLName(protocol,server,port,file,username,password);
// URLName urln = new URLName(CONST.maildir,CONST.mailhost,8008,maildir,userid,passwd);
Store store = s.getStore(urln);
s.setDebug(true); // true = s.getDebug() 有何实际意义???// URLName url = new URLName(protocol,getHostname(), -1, mbox,getUsername(),getPassword());
// Properties props = System.getProperties();
// props.put("mail.smtp.host",getHostname());
// Session session = Session.getDefaultInstance(props,null);
// Store store = session.getStore(url);
// store.connect(); try{
// store.connect(server,port,username,password);
store.connect();
}catch(MessagingException e){
throw new Exception("Cannot log on to server.Please verify the username and password.");
}
try{
String mbox = "INBOX";
Folder folder = store.getFolder(mbox);
folder.open(Folder.READ_ONLY);
Message[] messages = folder.getMessages();
for(int i=0;i<messages.length;i++){
InternetAddress[] from = (InternetAddress[])messages[i].getFrom();
InternetAddress[] to = (InternetAddress[])messages[i].
getRecipients(Message.RecipientType.TO);
%>
<p>To <%= to[0].getAddress() %>, from <%= from[0].getAddress() %>,
subject <%= messages[i].getSubject() %> </p>
<%
}
}catch(MessagingException e){
throw new Exception("Cannot read message.Please verify your E-mail server has a valid inbox");
}finally{
store.close();
}
%>