Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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·þÎñÆ÷¶ËList¶ÔÏóת»»ÎªJSON¶ÔÏó²¢·µ»Ø¿Í»§¶ËʵÀý


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

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

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

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

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

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

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