Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

smtp of java mail

send mail use smtp .u can send text or html, send to many peoples if u have a email user and pwd and the smtp of the email which u use.
package org.lc.smtp;
import java.io.IOException;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.util.ByteArrayDataSource;
import com.sun.mail.smtp.SMTPTransport;
/**
* smtp send mail.
* @author lc.
*/
public class smtp {
Message message;
Properties properties = new Properties();
Session session;
/**
*
* @param from mail from
* @param pwd mail pwd
* @param host mail from smtp host
* @param to to someone's mail
*/
public smtp(String from, String pwd, String host, String to) throws MessagingException, IOException {
properties.put("mail.smtp.host", host);// set smtp properties
session = Session.getInstance(properties);
message = new MimeMessage(session);
message.setSubject("title of mail");// set titile
message.setText("text");//send text
message.setDataHandler(new DataHandler(new ByteArrayDataSource("<a href="\" mce_href="\""http://www.baidu.com\">ahaha..</a>".toString(), "text/html")));// send html
message.setfrom(new InternetAddress(from));// set send from
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to,false));// set send where

SMTPTransport t = (SMTPTransport) session.getTransport("smtp");
t.connect(host, from, pwd);
t.sendMessage(message, message.getAllRecipients());
}

public static void main(String[] args) throws Exception {
new smtp(args[0], args[1], args[2], args[3]);
}

}


Ïà¹ØÎĵµ£º

java ¹ýÂËÆ÷£¨²ÎÊý´«µÝÖÐÎÄÂÒÂ룩

(Ò»)¹ýÂËÆ÷Àà±àд¡£ 
1¡¢ÉèÖÃ×Ö·û¼¯±àÂ뷽ʽ£º
      ±àд¹ýÂËÆ÷ÀࣺʵÏÖ½Ó¿Újavax.servlet.Filter
 public class CharacterEncodingFilter implements Filter {
private String charset;
public void destroy() {
// TODO Auto-generated method stub

}
public void ......

JAVAÖеÄλÒƲÙ×÷ >> >>

ÖÐС
JavaÖй²ÓÐÈý¸öÒÆλ²Ù×÷·û£¬·Ö±ðÊÇ£º
<<£º×óÒƲÙ×÷£¬ËùÓвÙ×÷ÊýÏò×óÒƶ¯£¬Ã¿ÒÆһλ×îÓÒ±ßÓÃ0²¹³ä
>>£º´ø·ûºÅλÓÒÒÆ£ºÁ¬Í¬·ûºÅλһÆðÓÒÒÆ£¬Ã¿ÒÆһλ×î×ó±ßÓ÷ûºÅλ²¹³ä
>>>£ºÎÞ·ûºÅÓÒÒÆ£ºÁ¬Í¬·ûºÅλһÆðÓÒÒÆ£¬Ã¿ÒÆһλ×î×ó±ßÓÃ0²¹³ä
ÒÆλ²Ù×÷·ûÖ»ÄÜ×÷ÓÃÓÚÕûÊýÀàÐÍ£¬¼´byte£¬short£¬char£¬i ......

Õë¶ÔJava¿ª·¢³ÌÐòµÄ±£»¤·½·¨

java¿ª·¢µÄ³ÌÐòµÄ±£»¤
 
 
 
ÖÚËùÖÜÖª£¬javaΪ¿ª·¢ÓïÑÔÌṩÁ˺ܷ½±ãµÄ¿ª·¢Æ½Ì¨£¬µ«¿ª·¢³öÀ´µÄ³ÌÐòºÜÈÝÒ×ÔÚ²»Í¬µÄƽ̨ÉÏÃæ±»ÒÆÖ²£¬ÏÖÔÚÔ½À´Ô½¶àµÄÈËʹÓÃËü¿ª·¢Èí¼þ¡£
      JavaÓÐËü·½±ãµÄÒ»¸ö·½Ã棬µ«ËüͬʱҲ´ø¸øÁË¿ª·¢ÕßÒ»¸ö·³ÄÕ£¬Õâ¾ÍÊDZ£»¤µÄ°ì·¨²»¶à£¬¶øÇÒ´ó¶àÊý²»ÊǺܺ ......

JAVA¶ÁÈ¡Íⲿ×ÊÔ´µÄ·½·¨

ÔÚjava´úÂëÖо­³£ÓжÁÈ¡Íⲿ×ÊÔ´µÄÒªÇó:ÈçÅäÖÃÎļþµÈµÈ,ͨ³£»á°ÑÅäÖÃÎļþ·ÅÔÚclasspathÏ»òÕßÔÚwebÏîÄ¿ÖзÅÔÚweb-infÏÂ.
1.´Óµ±Ç°µÄ¹¤×÷Ŀ¼ÖжÁÈ¡:
        try {
            BufferedReader in = new BufferedReader(new InputStreamRea ......

[JAVA] Éî¿Ë¡ ÁíÍâʵÏÖ·½·¨¡¾ÐòÁл¯¡¿

private static List cloneObject(
   Object obj) throws Exception {
  ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
  ObjectOutputStream out = new ObjectOutputStream(byteOut);
  out.writeObject(obj);
  ByteArrayInputStream byt ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ