Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ÐÅÑöÕߵĸæ½â

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

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

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

¶¨ÖÆÓëÀ©Õ¹Java¼¯ºÏ¿ò¼Ü

 ¸ÅÒª£ºJava¼¯ºÏAPIÔ¶²»Ö¹ÊÇÊý×éµÄÌæ´úÆ·£¬¾¡¹ÜÄÇÊÇÒ»¸ö²»»µµÄÈÏÖªÆðµã¡£Ted NewardչʾÁË5¸öÄܸü´óÀûÓü¯ºÏ¿ò¼ÜµÄÇÏÃÅ£¬°üº¬Ò»¸ö¶¨ÖƲ¢À©Õ¹Java¼¯ºÏAPIµÄÈëÃż¶Ó¦Óá£
    ¶ÔÓÚÐí¶àJava¿ª·¢Õß¶øÑÔ£¬Java¼¯ºÏAPIÊDZê×¼µÄJavaÊý×é¼°ÆäÈ«²¿È±µãµÄ±ØÒªÌæ´úÆ·¡£½«¼¯ºÏ¿ò¼ÜÖ÷ÒªÓëArrayListÁªÏµÆðÀ´²¢²»ÊÇÒ ......

java Öл·¾³±äÁ¿µÄÉèÖ÷½·¨

ºÃ¾ÃûÓÃjava£¬Í»Ò»Ð´ÆðÀ´£¬·¢ÏÖ»úÆ÷ÉÏûÓÐÉèÖû·¾³±äÁ¿£¬°ÑÉèÖ÷½·¨×ܽáÒ»ÏÂ
¡¡¡¡1. ÐÞ¸Ä/etc/profileÎļþ
¡¡¡¡¡¡¡¡Èç¹ûÄãµÄ¼ÆËã»ú½ö½ö×÷Ϊ¿ª·¢Ê¹ÓÃÊ±ÍÆ¼öʹÓÃÕâÖÖ·½·¨£¬ÒòΪËùÓÐÓû§µÄshell¶¼ÓÐȨʹÓÃÕâЩ»·¾³±äÁ¿£¬¿ÉÄÜ»á¸øÏµÍ³´øÀ´°²È«ÐÔÎÊÌâ¡£
¡¡¡¡¡¡¡¡·ÓÃÎı¾±à¼­Æ÷´ò¿ª/etc/profile
¡¡¡¡¡¡¡¡·ÔÚpr ......

[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ºÅ