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 ʵÏÖËãÊõ±í´ïʽ(1234324234324 + 8938459043545)/5 + 343434343432.59845
ÒòΪJAVAÓïÑÔÖеÄlong ¶¨ÒåµÄ±äÁ¿ÖµµÄ×î´óÊýÊܵ½ÏÞÖÆ£¬ÀýÈç123456789987654321ÕâÑùµÄÕûÊý¾Í²»ÄÜ´æ·ÅÔÚlongÀàÐ͵ıäÁ¿ÖУ¬Èç¹ûÕâÑùÁ½¸ö´óÊýÏà¼Ó»òÏà³Ë£¬²úÉúµÄ½á¹û»á¸ü´ó¡£±ÈÈ磬JAVAÓïÑÔÖÐÈç ......
ÔÚʹÓÃhibernate»òÕßspringµÄʱºò£¬ÎÒÃÇÍùÍùͨ¹ýÅäÖÃÎļþÅäÖÃÊý¾Ý¿âÁ¬½ÓÊôÐÔ¡£µ«Õâ´ÎÏîÄ¿Öв¢Ã»ÓÐÓõ½hibernateºÍspring£¬Ö»Óõ½ÁËstruts2¡£ÒªÈçºÎʵÏÖͨ¹ý¶ÁÈ¡ÎļþÅäÖûñÈ¡ÊôÐÔֵĨ£¿ResourceBundleÕâ¸öÀà¿ÉÊÇʵÏÖ¶ÁÈ¡propertiesÎļþÀ´»ñȡֵ
ÔÚjavaÖУº
public final static Object initLock = new Object();
privat ......
¸ÅÒª£ºJava¼¯ºÏAPIÔ¶²»Ö¹ÊÇÊý×éµÄÌæ´úÆ·£¬¾¡¹ÜÄÇÊÇÒ»¸ö²»»µµÄÈÏÖªÆðµã¡£Ted NewardչʾÁË5¸öÄܸü´óÀûÓü¯ºÏ¿ò¼ÜµÄÇÏÃÅ£¬°üº¬Ò»¸ö¶¨ÖƲ¢À©Õ¹Java¼¯ºÏAPIµÄÈëÃż¶Ó¦Óá£
¶ÔÓÚÐí¶àJava¿ª·¢Õß¶øÑÔ£¬Java¼¯ºÏAPIÊDZê×¼µÄJavaÊý×é¼°ÆäÈ«²¿È±µãµÄ±ØÒªÌæ´úÆ·¡£½«¼¯ºÏ¿ò¼ÜÖ÷ÒªÓëArrayListÁªÏµÆðÀ´²¢²»ÊÇÒ ......
µÚÒ»²¿·Ö£ºJavaÐéÄâ»úÆô¶¯Ê±£¬¹ØÓÚÀà¼ÓÔØ·½ÃæµÄһЩ¶¯×÷
µ±Ê¹ÓÃjava ProgramName.classÔËÐгÌÐòʱ£¬JavaÕÒµ½JRE£¬½Ó×ÅÕÒµ½jvm.dll£¬°Ñ¸Ã¶¯Ì¬¿âÔØÈëÄڴ棬Õâ¾ÍÊÇJVM¡£È»ºó¼ÓÔØÆäËü¶¯Ì¬¿â£¬ ²¢¼¤»îJVM¡£JVM¼¤»îÖ®ºó»á½øÐÐһЩ³õʼ»¯¹¤×÷£¬Ö®ºóÉú³ÉBootstrapLoader£¬¸ÃClass LoaderÊÇÓÉC++дµÄ¡£BootstrapLoader¼ÓÔØLaunche ......