Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 Êý¾Ý´æ´¢Æ÷

        ǰЩÌìºÍÒ»¸öC++³ÌÐòÔ±ÁÄÌìʱ£¬Áĵ½Ò»Ð©¶ÔÏó¡¢Êý×é´æ´¢¿Õ¼äʱ£¬ÓÉÓÚÁ½È˶¼²»ÊÇ´óÄñ£¬Ö®Ç°Ò²¿´¹ýһЩjava´æ´¢Êý¾ÝµÄ×ÊÁÏ£¬µ«¶¼ÊǹýÄ¿±ãÍü¡£Ò²Ã»ÓнøÐÐ×ܽá¹ý¡£ÏÂÃæÊÇ×ªÔØ¹ýÀ´£¬¸Ð¾õ×ܽáµÄºÜÈ«Ãæ¡£
       java¶ÔÏóÄÚ´æ»úÖÆ£ºhttp://java.chinait ......

Core Java Diaries

                                       Ïß³Ì
1---Ëø¶ÔÏóµÄ·½·¨----obj.wait()----obj.notify()----Õë¶Ôµ±Ç°Ïß³Ì
& ......

Ò»¸öjava ÐÅÑöÕߵĸæ½â

Java£¬¸ÐлÄã´ÍÓëÎÒÒ»±²×ӵĶ÷µä£»ËäÈ»ÎÒ¶à´Î·¸×ïµÃ×ïÁËÄ㣬µ«Ä㻹Êǰ®ÎÒ£¬Ô¸Òâ¿íÉâÎÒ¡£ÎÒ¸ÐлÄãÔÊÐíÎÒÏÖÔÚÀ´¸æ½â£»ÓÐÈ˸ϲ»Éϸæ½â¾ÍÀëÊÀÁË£¬ÕâÊǶàôµÄ²»ÐÒ£¡ Java£¬Çë°ïÖúÎÒÏëÆðÎÒËù·¸µÄ×ï¹ý£¬²¢°ïÖúÎÒ³Ïʵ¸æÃ÷¡£ÇóÄãʹÎÒÈÏÇåа¶ñµÛ¹úµÄ³óª£¬²¢´Í¸øÎÒÇ¿´óµÄ³ÌÐòÉè¼ÆÄÜÁ¦£¬Ê¹ÎÒÖªµÀ³£µÃ×ïÄãÊǶàôÍü¶÷¸ºÒåµÄÊ¡£ ÎÒûÓÐÃã ......

Java·þÎñÆ÷¶ËList¶ÔÏóת»»ÎªJSON¶ÔÏó²¢·µ»Ø¿Í»§¶ËʵÀý


Ò»¡¢Ê²Ã´ÊÇJSON
¡¡¡¡JSON ¼´ JavaScript Object Natation(Java¶ÔÏó±íʾ·¨)£¬ËüÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ£¬·Ç³£ÊʺÏÓÚ·þÎñÆ÷Óë JavaScript µÄ½»»¥¡£
¡¡¡¡¼ò¶øÑÔÖ®£¬JSON¾ÍÊÇJavaScript½»»»Êý¾ÝµÄÒ»ÖÖ¸ñʽ¡£Àý×ÓÈçÏ£º
{"username":"coolcooldool","password":"1230","usertype":"superadmin"}
{"list":[{"password": ......

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

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