后台自动发邮件 java代码
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class SendMail {
/**
* @param args
*/
public static void main(String[] args) {
Properties props = System.getProperties();
// 设置smtp服务器
props.setProperty("mail.smtp.host", "smtp.126.com");
// 现在的大部分smpt都需要验证了
props.put("mail.smtp.auth", "true");
Session s = Session.getInstance(props);
// 为了查看运行时的信息
s.setDebug(true);
// 由邮件会话新建一个消息对象
MimeMessage message = new MimeMessage(s);
try {
// 发件人
InternetAddress from = new InternetAddress("fasongren@126.com");
message.setfrom(from);
// 收件人
InternetAddress to = new InternetAddress("jieshouren@163.com");
 
相关文档:
不久前用到了同步,现在回过头来对JAVA中的同步做个总结,以对前段时间工作的总结和自我技术的条理话。JAVA中synchronized关键字能够作为函数的修饰符,也可作为函数内的语句,也就是平时说的同步方法和同步语句块。假如再细的分类,synchronized可作用于instance变量、object reference(对象引用)、static函数和class li ......
第1章 选择题
1.1 下列语句哪一个正确()
A. Java程序经编译后会产生machine code
B.Java程序经编译后会产生byte code
C.Java程序经编译后会产生DLL
D.以上都不正确
1.2 提供Java存取数据库能力的包是()
A.java.sql
B.java.awt
C.java ......
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
public class TestDesktop {
public static void main(String[] a) {
try {
Desktop desktop = null;
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
}
desktop.open(new File("/hom ......
JAVA 中URL链接中文参数乱码的若干处理方法,现在整理收录如下:
方法一:
http://xxx.do?ptname='我是中国人'
String strPtname = request.getParameter("ptname");
strPtname = new String(strPtname.getBytes("ISO-8859-1"), "UTF-8");
方法二:
<%@ page contentTy ......