




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、javamail 發(fā)送驗(yàn)證郵件(jsp/servlet實(shí)例源碼) 發(fā)送email:包括文本郵件、html郵件、帶附件的郵件、smtp驗(yàn)證 接收email:pop3遠(yuǎn)程連接、收取不同mime的郵件、處理附件 - 例子一、javamail.jsp 發(fā)送驗(yàn)證郵件源代碼 boolean sessiondebug = false authenticator auth = new authenticator()
2、; /session mailsession = session.getdefaultinstance(props auth) /有時(shí)可能被拒絕 session mailsession = session.getinstance(props auth) /用戶驗(yàn)證 /session mailsession = session.getinstance(props) ma
3、ilsession.setdebug(sessiondebug) string text = " javamail.jsp 發(fā)送認(rèn)證郵件< b> 測(cè)試< /b> 。< hr> " + contents msg.setcontent(text contenttype) transport transpor
4、t = mailsession.gettransport(" smtp" ) transport.connect(host user password) transport.send( msg ) > < p> 你的郵件已發(fā)送,< a href=" javascript:window.go(-1)" >
5、;請(qǐng)返回。< /> < /p> < catch(exception m)out.println(m.tostring() > < /body> < /html> - 例子二、用servlet來發(fā)送郵件 ,postmail.java 源代碼 public void
6、setaccount(string user string password) this.user=user this.password=password (mimemessage)message).setsubject(subject " gb
7、k" ) /得到中文標(biāo)題for linux,windows下不用 / message.setsubject(subject) /郵件主題 /內(nèi)容類型content-type /普通文本為text/plain html格式為text/ht
8、ml message.setcontent(content " text/html charset=gbk" ) /message.settext(" < html> < body> < h1> java mail,你好!< /body> &
9、lt; /html> " ) message.settext(content) /郵件內(nèi)容 message.savechanges() transport transp
10、ort = mailsession.gettransport(" smtp" ) transport.connect(host user password) transport.sendmessage(message message.getallrecipients()
11、160; public static void main(string args) / postmail sm=new postmail() / param string 發(fā)件人的地址
12、; param string 收件人地址 param string 郵件標(biāo)題 param string 郵件正文 / 調(diào)用post
13、mail.java的jsp文件:postmail.jsp源代碼 - 其他java源代碼:mailmanager.java 源代碼 package mail - sendmailusingauthentication.java 源代碼,引用這個(gè)java bean發(fā)送認(rèn)證email例子 package mail import java.util. / to
14、 use this program change values for the following three constants smtp_host_name - has your smtp host name smtp_auth_user - has your
15、60;smtp authentication username smtp_auth_pwd - has your smtp authentication password next change values for fields emailmsgtxt - message text fo
16、r the email emailsubjecttxt - subject for email emailfromaddress - email address whose name will appears as " from" address next change
17、160;value for " emaillist" . this string array has list of all email addresses to email email needs to be sent to. next to run the
18、;program ute it as follows sendmailusingauthentication authprog = new sendmailusingauthentication() / public class sendmailusingauthentication private static final
19、60;string emailmsgtxt = " online order confirmation message. also include the tracking number.中國(guó)人" private static final string emailsubjecttxt
20、60;= " 這里是標(biāo)題 java mail test" private static final string emailfromaddress = " user " / add list of email address to who
21、60;email needs to be sent to private static final string emaillist = " username " " xxxx " public void postmail( string re
22、cipients string subject /public void postmail( string recipients string subject
23、160; string message string from) throws messagingexception boolean debug = false authenticator auth = new smtpauthent
24、icator() /session session = session.getdefaultinstance(props auth) /有時(shí)可能被拒絕 session session = session.getinstance(props auth) session.setdebug(debug) / create a message message msg =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 倉(cāng)庫(kù)協(xié)議合同標(biāo)準(zhǔn)文本
- 三亞農(nóng)村平房買賣合同標(biāo)準(zhǔn)文本
- 會(huì)計(jì)咨詢合同標(biāo)準(zhǔn)文本
- 企業(yè)信息安全防護(hù)與緊急響應(yīng)機(jī)制構(gòu)建實(shí)踐案例分享
- 產(chǎn)品展架制作合同標(biāo)準(zhǔn)文本
- Module2 My house(教學(xué)設(shè)計(jì))-2024-2025學(xué)年教科版(廣州)英語四年級(jí)上冊(cè)
- ktv廚房合同標(biāo)準(zhǔn)文本
- 質(zhì)量管理知到課后答案智慧樹章節(jié)測(cè)試答案2025年春煙臺(tái)南山學(xué)院
- 智能化成本核算與管理知到課后答案智慧樹章節(jié)測(cè)試答案2025年春山東經(jīng)貿(mào)職業(yè)學(xué)院
- 關(guān)于承包食堂合同標(biāo)準(zhǔn)文本
- MT 181-1988煤礦井下用塑料管安全性能檢驗(yàn)規(guī)范
- 骨轉(zhuǎn)移瘤課件
- 三下語文作業(yè)樣例(第三單元)
- 護(hù)士注冊(cè)健康體檢表下載【可直接打印版本】
- 地源熱泵空調(diào)技術(shù)應(yīng)用介紹
- 雙星與多星問題
- 五年級(jí)下冊(cè)音樂教案-1編花籃-湘教版
- ESS嗜睡量表評(píng)分標(biāo)準(zhǔn)(Epworth 嗜睡量表(ESS))
- 住建部《建筑業(yè)10項(xiàng)新技術(shù)(2017版)》解讀培訓(xùn)課件
- 合作社組織架構(gòu)圖
- 《你知道嗎?》羅鳴亮
評(píng)論
0/150
提交評(píng)論