1、配置jdk,此處不再贅述,隨便搜一下然后照著操作即可
注意:后續(xù)james的版本是3.5.0,需要與jdk8配套
2、下載apache james ,apacheJames 下載之后可以直接運(yùn)行,無(wú)需安裝
注意:此處選擇3.5.0版本,因?yàn)楦甙姹九cjdk8不配套
Index of /dist/james/server/3.5.0
?
2、下載foxmail,用于后續(xù)進(jìn)行測(cè)試
Foxmail for Mac
?
3、安裝foxmail
雙擊前一步下載的foxmail包,傻瓜式下一步安裝即可
搭建ApacheJames郵件服務(wù)器
1、修改?mailetcontainer.xml,修改postmaster的值為postmaster@st.com
注意:下述@st.com為自定義的郵件域名,與@163.com類似
<context>
? ? <!-- When the domain part of the postmaster mailAddress is missing, the default domain is appended.
? ? You can configure it to (for example) <postmaster>postmaster@myDomain.com</postmaster> -->
? ? <postmaster>postmaster@st.com</postmaster>
</context>
2、修改?smtpserver.xml
將authRequired、verifyIdentity值配置為false
將helloName配置為st.com。注意與步驟1中保持一致
<authRequired>true</authRequired>
<verifyIdentity>true</verifyIdentity>
<helloName autodetect="true">st.com</helloName>
3、修改?domainlist.xml
將autodetect、autodetectIP的值配置為false
將defaultDomain配置為st.com。注意與步驟1中保持一致
<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
? ?<autodetect>false</autodetect>
? ?<autodetectIP>false</autodetectIP>
? ?<defaultDomain>st.com</defaultDomain>
</domainlist>
4、啟動(dòng)james
進(jìn)入james-server-app-3.5.0/bin目錄中,windows執(zhí)行run.bat,linux執(zhí)行sh run.sh
注意:windows中先打開(kāi)dos窗口,然后再執(zhí)行run.bat,直接在界面雙擊run.bat文件執(zhí)行,會(huì)啟動(dòng)失敗
5、創(chuàng)建域名
進(jìn)入james-server-app-3.5.0/bin目錄中
james-cli.bat -h localhost -p 9999 adddomain st.com
6、創(chuàng)建用戶
進(jìn)入james-server-app-3.5.0/bin目錄中,執(zhí)行如下命令,分別創(chuàng)建兩個(gè)用戶 steven@st.com(密碼:123456)、russell@st.com(密碼:123456)
james-cli.bat -h localhost -p 9999 adduser steven@st.com 123456
james-cli.bat -h localhost -p 9999 adduser russell@st.com 123456
7、?使用foxmail 連接james mail
此時(shí)james服務(wù)器已經(jīng)啟動(dòng)并且可以使用了,打開(kāi)foxmail,創(chuàng)建兩個(gè)用戶steven@st.com、russell@st.com,注意密碼和前面創(chuàng)建用戶的信息對(duì)應(yīng)
?
?
8、發(fā)送郵件
9、接收郵件,注意:若是郵件接收不及時(shí),可以手動(dòng)點(diǎn)擊左上角的收取按鈕,即可接收到最新的郵件
?開(kāi)啟james的ssl
1、從jre/lib/ext中拷貝sunjce_provider.jar到j(luò)ames-server-app-3.5.0/lib
2、在james-server-app-3.5.0/conf下生成keystore,直接在james-server-app-3.5.0/conf下執(zhí)行keytool命令,后續(xù)就不用重新將keystore文件移動(dòng)了
keytool -genkey -alias james -keyalg RSA -keystore keystore
?注意:
- 生成keystore的口令別忘了,后續(xù)配置會(huì)用到
- 名字與姓氏時(shí)輸入之前的域名st.com
- 后續(xù)的步驟可以直接回車跳過(guò)
3、修改smtpserver.xml
修改25端口為465
<bind>0.0.0.0:465</bind>
修改tls標(biāo)簽的屬性socketTLS=true,修改secret的值為創(chuàng)建證書(shū)時(shí)的口令密碼
? ? ?<tls socketTLS="true" startTLS="false">
? ? ? ?<!-- To create a new keystore execute:
? ? ? ? keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
? ? ? ? ?-->
? ? ? ?<keystore>file://conf/keystore</keystore>
? ? ? ?<secret>123456</secret>
? ? ? ?<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
? ? ? ?<!-- The algorithm is optional and only needs to be specified when using something other
? ? ? ? than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
? ? ? ?<algorithm>SunX509</algorithm>
? ? ?</tls>
4、重啟james-mail
進(jìn)入james-server-app-3.5.0/bin目錄中,windows執(zhí)行run.bat,linux執(zhí)行sh run.sh
注意:windows中先打開(kāi)dos窗口,然后再執(zhí)行run.bat,直接在界面雙擊run.bat文件執(zhí)行,會(huì)啟動(dòng)失敗
5、修改foxmail中的配置,將賬戶的服務(wù)器配置為465,并且點(diǎn)擊應(yīng)用
??6、進(jìn)行郵件發(fā)送和接收進(jìn)行驗(yàn)證,此處不再贅述,與前面未開(kāi)啟ssl時(shí)的操作一致
使用curl命令發(fā)送郵件
1、按照如下格式,創(chuàng)建文件 /root/email.txt
From: 發(fā)件人名稱?<發(fā)件人郵箱地址>
To: 收件人名稱 <收件人郵箱地址>
Subject: 郵件標(biāo)題
// 注意空一行
郵件內(nèi)容.
樣例如下:
From: steven <steven@st.com>
To: russell <russell@st.com>
Subject: an st.com example email
測(cè)試郵件內(nèi)容,steven ==> russell.
2、執(zhí)行curl命令
注意:
- 協(xié)議為:smtps
- 發(fā)送郵件內(nèi)容為步驟1創(chuàng)建的文件
- --user中指定的是發(fā)件人郵箱地址和密碼,用冒號(hào)分隔
curl -ikv --url 'smtps://192.168.133.135:465' --mail-from 'steven@st.com' --mail-rcpt 'russell@st.com' --upload-file /root/email.txt --user 'steven@st.com:123456'
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-499649.html
3、查看發(fā)送的郵件
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-499649.html
?
到了這里,關(guān)于Apache James郵件服務(wù)器搭建(linux)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!