利用hMailServer搭建邮件服务器并进行DISCUZ后台邮件设置
一直在论坛白嫖技术,刚刚自己也抱着试一试的心态弄了一哈,没想到居然成功了,所以就把经验分享出来大家一起研究。<br /><br /><img title="QQ截图20230906140811.png" id="aimg_24839" aid="24839" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/140833yf4cibc3iklii4zb.png" src="https://www.dismall.com/data/attachment/forum/202309/06/140833yf4cibc3iklii4zb.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />后台设置,除了密码打了个马赛克其他没啥好隐藏的<br /><img title="QQ截图20230906140921.png" id="aimg_24840" aid="24840" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/140941qqyigqdd6u916ufk.png" src="https://www.dismall.com/data/attachment/forum/202309/06/140941qqyigqdd6u916ufk.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />测试接收成功的邮件<br />邮件<em>, </em>成功<em>, </em>一直<em>, </em>论坛<em>, </em>白嫖 <br /><br />前言<br />假设你已经拥有了一台具有公网ip的服务器,以及域名<br />hMailServer 介绍<br />hMailServer 适用于 Windows 操作系统,它除了提供邮箱系统需要的所有基础功能之外,还内置了一些常用功能,比如:反垃圾邮件、反病毒邮件,而其他未内置的功能,则可以根据用户需要,自行去社区中寻找相应的插件来进行扩展<br /><br />邮件协议介绍<br />在搭建邮箱系统之前,需要先了解一些前置知识,比如常见的邮件协议:SMTP、POP3、IMAP 等<br /><br />SMTP<br />SMTP 即 Simple Mail Transfer Protocol,它用于将邮件投递到邮箱服务器,即邮件的发送,例如:将邮件从邮箱客户端发送到邮箱服务器、邮箱服务器将邮件转发给另一个邮箱服务器,如下:<br /><br /><img title="1.png" id="aimg_24841" aid="24841" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143220q444wv4ixz49zx19.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143220q444wv4ixz49zx19.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />POP3<br />POP3 即 Post Office Protocol 3,它用于从邮箱服务器取回邮件,即邮件的接收,例如:邮箱客户端从邮箱服务器取回邮件,如下:<br /><img title="2.png" id="aimg_24842" aid="24842" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143220nit3am287is32y8a.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143220nit3am287is32y8a.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />另,POP3 是最简单的邮件接收协议,它只提供基础的功能,缺少一些常用特性,因此使用该协议的情况较少<br /><img title="3.png" id="aimg_24843" aid="24843" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143220swwuok22agkkw2rg.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143220swwuok22agkkw2rg.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />IMAP<br />IMAP 即 Internet Message Access Protocol,它同 POP3 一样,是用于邮件接收的协议,如下:<br /><br />同 POP3 相比,IMAP 支持更多的特性,它们具有以下区别:<br /><br />POP3 接收邮件的方式为 ‘取’,即接收邮件之后,邮箱服务器将删除已接收邮件,进而释放其占用的空间<br /><br />IMAP 接收邮件的方式为 ‘读’,即接收邮件之后,邮箱服务器仍保留已接收邮件,因此使用 IMAP 协议的邮箱服务器需要更大的存储空间<br /><br />POP3 在客户端对邮件的操作,例如删除邮件、阅读邮件等,不会同步到服务器端(我们上一点提到的,服务器端已经将邮件删除,因此不会再有更多操作了)<br /><br />IMAP 在客户端的操作,例如删除邮件、阅读邮件等,可以同步到服务器端<br /><br />POP3 只有在接收到完整的邮件后,才能阅读邮件主体内容及发件人、主题等摘要信息<br /><br />IMAP 可以先接收邮件的摘要信息,对发件人、主题等等进行判断后,再确认是否接收该邮件<br /><br />DNS 域名解析<br />我们常常访问,例如 www.baidu.com,其中 baidu.com 是主域名,而前面的 www,表示该域名指向的服务器提供的是万维网(World Wide Web)服务,即网站服务<br /><br />现在我们的服务器要提供的是邮箱服务,因此也应该有一个域名指向该服务器,并且前缀应该是 mail,我的主域名是 xcqbm.com,因此邮箱服务器的域名是:mail.xcqbm.com<br /><br />配置 A 记录<br />我是在腾讯云购买的云服务器及域名作开发测试用,因此我将在腾讯云的域名管理面板,来配置域名的解析,如下:<br /><img title="4.png" id="aimg_24844" aid="24844" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143221lf2aft2ll9gjgg2l.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143221lf2aft2ll9gjgg2l.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />如前所述,我先配置 mail.xcqbm.com 指向我的服务器 ip,这种由域名直接指向具体ip的记录类型,我们称为 A 记录,如下:<br /><img title="5.png" id="aimg_24845" aid="24845" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143221aaz1gtatwu3fwppa.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143221aaz1gtatwu3fwppa.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />配置 MX 记录<br />邮箱地址格式通常是:用户名@邮箱服务器域名,例如: tanleidd@163.com,通过对 163.com 进行 DNS 解析,就可以得到邮箱服务器 ip,如下:<br /><br />上一步我们对 mail.xcqbm.com 进行了配置,如果直接使用它的话,邮箱地址就成了:xxx@mail.xcqbm.com,这样不够简洁,我们想要的效果是 xxx@xcqbm.com,于是再进行如下配置:<br /><br /><img title="6.png" id="aimg_24846" aid="24846" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143221y3nflvf3onoolovw.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143221y3nflvf3onoolovw.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />以上,@ 表示直接配置主域名,即xcqbm.com。我们将记录值设置为 mail.xcqbm.com ,间接的把主域名也指向了我们的IP地址,这样就可以通过 xxx@xcqbm.com,来访问到我们的邮箱服务器了,<br /><br />那为什么记录类型要配置成 MX 呢?<br /><br />MX 是指 Mail eXchanger,是专用于邮箱服务的记录类型,该记录类型支持配置MX优先级,优先级数值越小表示优先级越高,假如你有多台服务器,那么你可以给他们配置不同的优先级,这样在解析时会优先分配优先级高的服务器对外提供服务,当优先级高的服务器出现故障时,再分配优先级低的服务器提供服务。<br />配置防火墙<br />通常云服务器为了自身安全考虑,不会将全部端口都对外开放,外部应用无法访问服务器未开放的端口,我们的邮箱服务器的协议,如 SMTP、POP3、IMAP 规定了使用的固定端口,因此我们需要在防火墙配置中,将这些端口对外开放<br /><br />标准端口如下:<br /><br />因为我只使用 SMTP、IMAP 协议,并且没有 SSL 证书,所以再额外开放 25、143 端口即可,如下:<br /><br /><br /><img title="7.png" id="aimg_24847" aid="24847" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143221t0wyp3423muzhuo2.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143221t0wyp3423muzhuo2.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br /><br />hMailServer 安装&配置,hMailServer 可以在宝塔面板进行安装,也可以在网上搜一下,很多的<br /><br />安装步骤就不详细介绍了,很简单<br /><br /><br />配置<br />运行 Administrative tools,会提示连接 Server,我们的 Server 就在本地,因此选择 localhost,如下:<br /><img title="8.png" id="aimg_24848" aid="24848" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143221a4uwyhdwfm8lbzfv.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143221a4uwyhdwfm8lbzfv.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />点击 Connect,输入安装时设置的密码进行连接,<br /><img title="9.png" id="aimg_24849" aid="24849" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143221qzxkc37ojf22l757.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143221qzxkc37ojf22l757.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><img title="10.png" id="aimg_24850" aid="24850" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143222qrawfwsp5ba5pnpu.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143222qrawfwsp5ba5pnpu.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />登录后也可以在这里设置中文<br /><img title="11.png" id="aimg_24851" aid="24851" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143222m90qqiko43i1ffi4.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143222m90qqiko43i1ffi4.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />登录成功后,配置界面如下,我们先添加域名:<br />在常规中输入我们之前配置过的主域名:xcqbm.com,并保存<br /><br /><br /><img title="12.png" id="aimg_24852" aid="24852" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143222xr6qy6zib67xi4u6.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143222xr6qy6zib67xi4u6.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />添加成功后,Domains 下会出现 xcqbm.com 目录,点击账号,进行账号添加:<br /><img title="13.png" id="aimg_24853" aid="24853" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143222a8nl24zo5zpm5m6c.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143222a8nl24zo5zpm5m6c.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />输入邮箱地址、密码,并保存:<br /><img title="14.png" id="aimg_24854" aid="24854" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143222jff7hfffnhcffssc.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143222jff7hfffnhcffssc.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />对新创建的邮箱设置自动回复,后续我们将用来测试邮箱服务器是否已经可以正确的收信、发信<br /><br /><img title="15.png" id="aimg_24855" aid="24855" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143222cymtlx8estws5wyw.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143222cymtlx8estws5wyw.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />另外,在邮件转发时,如果自身没有域名标识,邮件可能会被其他邮箱服务器拒收,因此我们还需要设置服务器域名,输入 mail.xcqbm.com 这也是我们前面在域名里配置过的<br /><br />邮箱测试<br /><br />经过上述操作,邮箱服务器已经配置好了,我们通过上面的自动回复功能,来测试邮箱服务器是否可以正确收发邮件<br /><img title="16.png" id="aimg_24856" aid="24856" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143223v7hd9wc8hpsefe61.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143223v7hd9wc8hpsefe61.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />我先用自己的邮箱向刚刚搭建好的邮箱服务器发送邮件:<br /><br />然后查看邮箱,是否收到自动回复,如上图。<br /><br />同时,我们也可以看到,admin@xcqbm.com账号下邮件占用的空间增加了:<br /><img title="17.png" id="aimg_24857" aid="24857" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143223k47qz5s5qu5smw46.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143223k47qz5s5qu5smw46.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />测试成功,一切正常。<br /><br />配置邮箱客户端<br />我们前面的操作,配置的是邮箱服务器,现在呢,我们需要使用邮箱客户端来连接邮箱服务器,进而使用邮箱服务器提供的服务<br /><br />这里我使用网易邮箱(移动端)进行配置,操作路径:设置 -> 邮箱管理 -> 添加邮箱 -> 手动配置,如下:<br /><br /><img title="18.jpg" id="aimg_24858" aid="24858" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143223dhvy99vhtttpl9bb.jpg" src="https://www.dismall.com/data/attachment/forum/202309/06/143223dhvy99vhtttpl9bb.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />上面可以看到,我们又增加了两个域名:imap.xcqbm.com、smtp.xcqbm.com,分别表示收信、发信服务器的位置,因为我们只有一台服务器,且由它来提供 imap、smtp 服务,因此只需要在域名解析里添加两条相关记录指向该服务器即可:<br /><img title="20.png" id="aimg_24860" aid="24860" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143224s1vvt9fj1z7i1ig7.png" src="https://www.dismall.com/data/attachment/forum/202309/06/143224s1vvt9fj1z7i1ig7.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br /><br />点击完成,确认服务器配置,如果成功,可以看到如下页面,下面的一封未读邮件是刚刚进行收发测试时产生的:<br /><br /><img title="19.jpg" id="aimg_24859" aid="24859" src1="static/image/common/none.gif" zoom="https://www.dismall.com/data/attachment/forum/202309/06/143223xok5i7kc2kcw7qei.jpg" src="https://www.dismall.com/data/attachment/forum/202309/06/143223xok5i7kc2kcw7qei.jpg" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="600" inpost="1" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /><br /><br />到此为止,配置相关的教程全部结束。<br /><br />可能出现的问题<br />邮件收发测试中,未收到回复<br />首先到邮箱账号页面看下,邮件存储是否增加,如果未变则表示邮箱服务器没收到邮件,因此也不会回复:<br />确认收到邮件之后,检查配置 自动回复 时,是否勾选了 自动过期:<br />因为自动过期的日期默认是今天,所以如果勾选,并且未改日期,相当于自动回复的功能在配置成功后又立马失效了,建议测试时不要勾选自动过期,避免不必要的麻烦<br />邮件收发测试中,仅收到过一次回复<br />仅第一次向 admin@xcqbm.com,发送邮件时得到回复,后续再发就不被回复。<br /><br />这样的情况是正常合理的,因为自动回复的内容是固定的,多次重复回复相同的内容没有意义。在测试时,你可以用不同的邮箱账号向 admin@xcqbm.com发送邮件,例如,我用 163 邮箱、QQ 邮箱,分别向其发送邮件,两者都仅在第一次时成功收到回复<br /><br />或者,你可以在收到第一次回复后,再重新设置自动回复功能,这样你可以再收到一次自动回复<br /><br />以上教程部分取自CSDN的作者tanleiDD<br /><br />
頁:
[1]