国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

郵件發送簡單例子-bean文件

2024-07-21 02:14:09
字體:
來源:轉載
供稿:網友


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 = "[email protected]";
string from = "[email protected]";
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();
}
}
}


,歡迎訪問網頁設計愛好者web開發。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 法库县| 三江| 鹤峰县| 彭泽县| 庄浪县| 怀宁县| 水城县| 陵水| 赞皇县| 玉山县| 靖远县| 渭源县| 宁晋县| 星座| 乃东县| 启东市| 建宁县| 城固县| 彰化市| 廉江市| 徐州市| 大足县| 黄山市| 靖安县| 确山县| 布拖县| 治多县| 承德市| 阳原县| 吕梁市| 芮城县| 买车| 兰考县| 天长市| 岑巩县| 西青区| 宁乡县| 玛沁县| 双流县| 沐川县| 上高县|