import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SimpleSendMessage {

public static void main(String[] args) { " /> 综合毛片免费视频,欧美日韩中字,成人h在线播放

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

郵件發(fā)送簡(jiǎn)單例子-bean文件

SimpleSendMessage.Java

import Java.util.*;

import Javax.mail.*;
import Javax.mail.interNET.*;
import Javax.activation.*;

public class SimpleSendMessage {

public static void main(String[] args) {

// Collect the necessary information to send a simple message
// Make sure to replace the values for host, to, and from with
// valid information.
// host - must be a valid smtp server that you currently have
// access to.
// to - whoever is going to get your email
// from - whoever you want to be. Just remember that many smtp
// servers will validate the domain of the from address
// before allowing the mail to be sent.
String host = "server.myhost.com";
String to = "YourFriend@somewhere.com";
String from = "MeMeMe@myhost.com";
String subject = "JSP Rules!";
String messageText = "I am sending a message using the"
+ " JavaMail API./nI can include any text that I want.";
boolean sessionDebug = false;

// Create some properties and get the default Session.
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");

Session session = Session.getDefaultInstance(props, null);

// Set debug on the Session so we can see what is going on
// Passing false will not echo debug info, and passing true
// will.
session.setDebug(sessionDebug);

try {

// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(session);

msg.setFrom(new InterNETAddress(from));
InterNETAddress[] address = {new InterNETAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);

// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
}
catch (MessagingException mex) {

mex.printStackTrace();
}
}
}

jsp技術(shù)郵件發(fā)送簡(jiǎn)單例子-bean文件,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 汤原县| 长子县| 南投县| 永登县| 专栏| 资源县| 江都市| 仪陇县| 新民市| 珠海市| 平遥县| 秦安县| 巧家县| 尼勒克县| 吉水县| 栾城县| 济源市| 砀山县| 翁源县| 哈巴河县| 梁河县| 武鸣县| 台安县| 昌乐县| 太康县| 金溪县| 炎陵县| 澄迈县| 和林格尔县| 镇原县| 明溪县| 龙游县| 房产| 丽水市| 连云港市| 嫩江县| 柏乡县| 贞丰县| 大足县| 涞源县| 荆州市|