配置 Exim4 SMTP 中继服务器
本文将指导您配置 Exim4 SMTP 中继服务器,该服务器仅允许您为已知的域名和 IP 地址转发电子邮件。通常,此类服务用于转发服务器运行状况状态报告的通知电子邮件,其中实际电子邮件地址不存在或发送自动回复电子邮件。
简介
Exim4 是剑桥大学开发的一种邮件传输代理 (MTA),用于连接到互联网的 Unix 系统。可以安装 Exim4 来替换 Sendmail 或 Postfix,尽管 Exim4 的配置与 sendmail 的配置大相径庭。
安装
要安装 exim4,请使用以下命令:
# hostname testserver.com # sudo –i (to Enter with root permissions) # apt-get update # apt-get install exim4
示例输出应如下所示:
Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: exim4-base exim4-config exim4-daemon-light heirloom-mailx Suggested packages: mail-reader eximon4 exim4-doc-html exim4-doc-info spf-tools-perl swaks Recommended packages: mailx The following NEW packages will be installed: exim4 exim4-base exim4-config exim4-daemon-light heirloom-mailx 0 upgraded, 5 newly installed, 0 to remove and 66 not upgraded. Need to get 1,862 kB of archives. After this operation, 4,258 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4-config all 4.86-3 ubuntu1 [299 kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4-base amd64 4.86-3ubuntu1 [869 kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4-daemon-light amd64 4.86-3ubuntu1 [465 kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4 all 4.86-3ubuntu1 [7,916 B] Get:5 http://us.archive.ubuntu.com/ubuntu/ wily/universe heirloom-mailx amd64 12.5-5 [221 kB] Fetched 1,862 kB in 49s (37.7 kB/s) Preconfiguring packages ... Selecting previously unselected package exim4-config. (Reading database ... 91615 files and directories currently installed.) Preparing to unpack .../exim4-config_4.86-3ubuntu1_all.deb ... Unpacking exim4-config (4.86-3ubuntu1) ... ................................................
我们需要配置 exim4 来中继电子邮件。
# dpkg-reconfigure exim4-config
输出应如下所示:
选择 **“internet site; mail is sent and received directly using SMTP”** 选项

提供 **Exim4 SMTP** 服务器的服务器名称。默认情况下,它将采用机器的主机名。

提供您要从中接收请求并发送电子邮件的 IP 地址。
在这里,您可以为多个 IP 提供用分号分隔的 IP 地址列表。

输入此 SMTP 将为其转发邮件的客户端接收方域的域名地址。
请注意,您可以为多个域提供用分号分隔的域名地址列表。

输入此系统将无条件转发邮件的 IP 地址范围的用分号分隔的列表。(充当智能主机)。这通常是将要使用的本地主机。

将 **保持 DNS 查询数量最少 (按需拨号)** 选择为 **否**(以前,我们使用的是拨号连接,但目前大多数互联网用户都使用宽带连接)

选择本地邮件的传递方法。在这里,我已经在 **home** **目录**中选择了 **Maildir 格式**

将 **将配置拆分为小文件?** 选择为 **否**。如果您有兴趣将配置存储到小文件中,则可以选择 **是**
现在您已完成,您的 SMTP 服务器已准备好转发任何通知发送的电子邮件。在 SMTP 服务器地址配置中使用此机器的 IP 地址,或者如果已注册域名,则使用域名。
配置后,我们可以使用相同的配置命令添加客户端,或者可以直接编辑配置文件并将其他客户端添加到此 SMTP 服务器中使用。
打开配置文件并编辑或添加客户端 IP 或域名
# vi /etc/exim4/update-exim4.conf.conf
**update-exim4.conf.conf** 文件应如下所示:
## Edit this file and /etc/mailname by hand and execute update-exim4.conf # yourself or use 'dpkg-reconfigure exim4-config'# # Please note that this is _not_ a dpkg-conffile and that automatically changes # to this file might happen. The code handling this will honor your local # changes, so this is usually fine, but will break local schemes that mess # around with multiple versions of the file. ## update-exim4.conf uses this file to determine variable values to generate # exim configuration macros for the configuration file. ## Most settings found in here do have corresponding questions in the # Debconf configuration, but not all of them. ## This is a Debian specific file dc_eximconfig_configtype='internet' dc_other_hostnames='server.com' dc_local_interfaces='127.0.0.1' dc_readhost='' dc_relay_domains='192.168.1.1' dc_minimaldns='false' dc_relay_nets='cgi.com' dc_smarthost='' CFILEMODE='644' dc_use_split_config='false' dc_hide_mailname='' dc_mailname_in_oh='true' dc_localdelivery='maildir_home'
现在,使用分号分隔符编辑配置中的以下行
dc_relay_nets 用于添加客户端/服务器的 IP 地址
dc_relay_domains 用于添加客户端/服务器的域名
成功配置后,您可以使用此服务器从您的服务器和客户端发送或转发电子邮件,以发送程序或项目的通知。
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP