Apache James 同时开启25、587、465端口

前提:

可以参考如下两篇文章在window或者linux上,先部署好Apache James

Apache James邮件服务器搭建(linux)_Steven-Russell的博客-CSDN博客

Apache James邮件服务器搭建(windows)_Steven-Russell的博客-CSDN博客

修改配置文件,使得邮件服务器同时支持如下协议

端口 协议
25   smtp
587smtp+startTLS
465smtps

编辑 james-server-app-3.5.0/conf/smtpserver.xml

在smtpservers标签中,修改为如下配置,分别代表smtp、smtp+startTLS、smtps三种协议

注意:

  • jmxName的名字不能重复
  • 博主使用的是Apache James 3.5.0版本,下述的操作仅针对3.5.0版本,其他版本应该修改方法类似,可以对照注释进行修改
  • 下述修改重点关注标红部分内容

25端口:smtp

<smtpserver enabled="true">

     <jmxName>smtpserver</jmxName>

     <bind>0.0.0.0:25</bind>

     <connectionBacklog>200</connectionBacklog>

     <tls socketTLS="false" startTLS="false">

       <keystore>file://conf/keystore</keystore>

       <secret>123456</secret>

       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>

       <algorithm>SunX509</algorithm>

     </tls>

        <helloName autodetect="true">st.com</helloName>

        <connectiontimeout>360</connectiontimeout>

        <connectionLimit>0</connectionLimit>

        <connectionLimitPerIP>0</connectionLimitPerIP>

        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <maxmessagesize>0</maxmessagesize>

        <addressBracketsEnforcement>true</addressBracketsEnforcement>

        <handlerchain>

            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>

            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>      

        </handlerchain>          

   </smtpserver>

587端口:smtp+startTLS

<smtpserver enabled="true">

     <jmxName>startTlsserver</jmxName>

     <bind>0.0.0.0:587</bind>

     <connectionBacklog>200</connectionBacklog>

     <tls socketTLS="false" startTLS="true">

       <keystore>file://conf/keystore</keystore>

       <secret>123456</secret>

       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>

       <algorithm>SunX509</algorithm>

     </tls>

        <helloName autodetect="true">st.com</helloName>

        <connectiontimeout>360</connectiontimeout>

        <connectionLimit>0</connectionLimit>

        <connectionLimitPerIP>0</connectionLimitPerIP>

        <authRequired>true</authRequired>

        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <verifyIdentity>true</verifyIdentity>

        <maxmessagesize>0</maxmessagesize>

        <addressBracketsEnforcement>true</addressBracketsEnforcement>

        <handlerchain>

            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>

            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>  

        </handlerchain>          

   </smtpserver>

465端口:smtps

<smtpserver enabled="true">

     <jmxName>smtpsserver</jmxName>

     <bind>0.0.0.0:465</bind>

     <connectionBacklog>200</connectionBacklog>

     <tls socketTLS="true" startTLS="false">

       <keystore>file://conf/keystore</keystore>

       <secret>123456</secret>

       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>

       <algorithm>SunX509</algorithm>

     </tls>

        <helloName autodetect="true">st.com</helloName>

        <connectiontimeout>360</connectiontimeout>

        <connectionLimit>0</connectionLimit>

        <connectionLimitPerIP>0</connectionLimitPerIP>

        <authRequired>true</authRequired>

        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <verifyIdentity>true</verifyIdentity>

        <maxmessagesize>0</maxmessagesize>

        <addressBracketsEnforcement>true</addressBracketsEnforcement>

        <handlerchain>

            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>

            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>

        </handlerchain>          

   </smtpserver>

smtpserver.xml 修改之后的总体内容如下

<?xml version="1.0"?>

<smtpservers>

   <smtpserver enabled="true">

     <jmxName>smtpserver</jmxName>

     <bind>0.0.0.0:25</bind>

     <connectionBacklog>200</connectionBacklog>

     <tls socketTLS="false" startTLS="false">

       <keystore>file://conf/keystore</keystore>

       <secret>123456</secret>

       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>

       <algorithm>SunX509</algorithm>

     </tls>

        <helloName autodetect="true">st.com</helloName>

        <connectiontimeout>360</connectiontimeout>

        <connectionLimit>0</connectionLimit>

        <connectionLimitPerIP>0</connectionLimitPerIP>

        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <maxmessagesize>0</maxmessagesize>

        <addressBracketsEnforcement>true</addressBracketsEnforcement>

        <handlerchain>

            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>

            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>      

        </handlerchain>          

   </smtpserver>

   <smtpserver enabled="true">

     <jmxName>startTlsserver</jmxName>

     <bind>0.0.0.0:587</bind>

     <connectionBacklog>200</connectionBacklog>

     <tls socketTLS="false" startTLS="true">

       <keystore>file://conf/keystore</keystore>

       <secret>123456</secret>

       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>

       <algorithm>SunX509</algorithm>

     </tls>

        <helloName autodetect="true">st.com</helloName>

        <connectiontimeout>360</connectiontimeout>

        <connectionLimit>0</connectionLimit>

        <connectionLimitPerIP>0</connectionLimitPerIP>

        <authRequired>true</authRequired>

        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <verifyIdentity>true</verifyIdentity>

        <maxmessagesize>0</maxmessagesize>

        <addressBracketsEnforcement>true</addressBracketsEnforcement>

        <handlerchain>

            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>

            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>  

        </handlerchain>          

   </smtpserver>

   <smtpserver enabled="true">

     <jmxName>smtpsserver</jmxName>

     <bind>0.0.0.0:465</bind>

     <connectionBacklog>200</connectionBacklog>

     <tls socketTLS="true" startTLS="false">

       <keystore>file://conf/keystore</keystore>

       <secret>123456</secret>

       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>

       <algorithm>SunX509</algorithm>

     </tls>

        <helloName autodetect="true">st.com</helloName>

        <connectiontimeout>360</connectiontimeout>

        <connectionLimit>0</connectionLimit>

        <connectionLimitPerIP>0</connectionLimitPerIP>

        <authRequired>true</authRequired>

        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <verifyIdentity>true</verifyIdentity>

        <maxmessagesize>0</maxmessagesize>

        <addressBracketsEnforcement>true</addressBracketsEnforcement>

        <handlerchain>

            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>

            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>

        </handlerchain>          

   </smtpserver>

</smtpservers>

修改完smtpserver.xml之后,重新启动james,可以查看端口情况如下

之后便可以分别使用不同的端口发送邮件了

 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'

curl -ikv --url 'smtp://192.168.133.135:587' --mail-from 'steven@st.com' --mail-rcpt 'russell@st.com' --upload-file /root/email.txt --user 'steven@st.com:123456'

curl -ikv --url 'smtp://192.168.133.135:25' --mail-from 'steven@st.com' --mail-rcpt 'russell@st.com' --upload-file /root/email.txt --user 'steven@st.com:123456'

当前25端口使用curl命令会报login denied,暂未找到解决办法,但是使用java代码调用时却是没问题的,待后续研究解决

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值