Linux Configure Sendmail for Email Service
Preface Due to development needs, I set up a wiki system and utilized email subscriptions, which led me to research various methods for sending emails. Installation There’s nothing special to say; first, install the necessary components. apt install sendmail-bin apt install sendmail apt install sendmail-cf #Configuration tool Configuring sendmail By default, sendmail is set to send emails from local users to local users. To enable sending to the entire Internet, you need to modify the configuration: Modify se
目录19 个章节
Preface
Due to development needs, I built a wiki系统 (wiki system) and used email subscription, so I researched various methods for sending emails.
Installation
There's nothing much to say, just install the necessary components first.
apt install sendmail-bin
apt install sendmail
apt install sendmail-cf # Configuration tool
Configure sendmail
sendmail is by default set up to send emails only locally on the machine. Therefore, it needs to be modified to allow sending emails across the entire Internet:
Modify the sendmail configuration macro file, located at /etc/mail/sendmail.mc
Find
DAEMON_OPTIONS('Family=inet, Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
Change Addr=127.0.0.1 to Addr=0.0.0.0, which allows connections to any server.
Save the modified file, then back up the configuration file:
cd /etc/mail
mv sendmail.cf sendmail.cf~
Next, generate a new configuration file:
m4 sendmail.mc > sendmail.cf
Restart sendmail for the changes to take effect.
Configuring Domain Names
Configuring sendmail to use a legitimate domain name involves two steps: modifying sendmail's configuration file and adding the domain's MX record.
sendmail can directly use the -r account@domain.com parameter to send emails from any source address. However, most mainstream email providers will compare the source address with the reverse DNS resolution of the IP. If the resolution fails or the resolved IP doesn't match, the email might be classified as SPAM or, in worse cases, be outright rejected.
The MX Record (Mail Exchanger Record) is primarily used for receiving emails. When delivering a new email, the system queries the MX record of the recipient's domain and uses the IP address obtained from the MX record to proceed with delivery. Additionally, email providers often compare the source address with the MX record when receiving emails, using it as one of the criteria for identifying spam.
Step 1: Add the Domain
(1) Add the domain to the local-host-names file
Open: /etc/mail/local-host-names
Add:
deali.cn
(2) Modify the submit.cf file
Open: vi /etc/mail/submit.cf, find the line #Dj$w.Foo.COM, and modify it to
Djdeali.cn
Attention! It must be in the format of Dj + Domain!
At this point, the sendmail email naming configuration is complete. Restart sendmail to apply the configuration.
Step 2: Add Domain MX Records
Navigate to the page where you can modify your domain information (this page varies by domain registrar). The changes may take up to 24 hours to take effect, depending on the registrar.
(1) Add an A record for the mail subdomain, pointing directly to your mail server's static IP address:
| Domain | Type | Record |
|---|---|---|
| A | 127.0.0.1 |
(2) Add (or modify) your domain's MX record in the following format:
| Domain | Type | Record |
|---|---|---|
| @ | MX | deali.cn |
(3) Use nslookup to verify that the MX record correctly resolves to your mail server.
nslookup
> set q=mx
> deali.cn
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
deali.cn mail exchanger = 5 deali.cn.
Authoritative answers can be found from:
Email Send Test
Enter the following command:
sendmail -t <<EOF
A > prompt will appear, then input the content in the format below (press Enter after each line):
From:Mail test <test@yourdomain.com>
To:xxxx@qq.com
Subject:Test
test
EOF
See the question
Relaying denied(Relaying denied)
When the error 550 5.7.1 <xxx@163.com>... Relaying denied. IP name lookup failed [192.168.1.133] occurs, the reason is that sendmail is being used as a mail relay. To resolve this, you need to add the client's IP address to the access configuration file.
Open: /etc/mail/access, and add the following:
Connect:Client_IP RELAY
Then, regenerate the access permissions database:
cd /etc/mail/
makemap hash access.db < access
Sent Emails Being Identified as Spam by Other MTAs
Set up domain pointing (link to the previous section) and add SPF records Operation Tutorial Also, pay attention to controlling the email sending frequency.
Where to Check Sendmail Logs?
Log location: /var/log/maillog
To adjust the log level (verbosity): modify the configuration file define(confLOG_LEVEL',16')dnl(default is9), or specify when calling the command: sendmail -O LogLevel=14`
What do sendmail logs mean?
Note that sendmail does not guarantee that the sent email will always be delivered to the recipient, so the information in the logs is only the connection information fed back by the receiving end's MTA.
For the specific format, feel free to read through it—–sendmail log format
Sendmail Performance Parameters
http://www.5dmail.net/html/2008-4-27/200842733006.htm
Some related websites and articles
http://www.5dmail.net/ Sendmail official site All about email sending Viewing email headers
_EOF_
Linux Configure Sendmail for Email Service
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
Ubuntu-16-04-安装配置Docker
安装相关包 $ sudo apt-get update # 先更新一下软件源库信息 $ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common 添加软件仓库 官方仓库 # 添加 Docker 官方的 GPG 密钥(为了确认所下载
2025-10-27 · 系统配置 · 约 1 分钟
Ubuntu-18-04-开启托盘图标点击最小化
前言 Ubuntu的托盘挺好看的,美中不足的就是点击一个打开的应用图标不能像Windows那样最小化。 操作 gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize' 截图
2025-10-27 · 系统配置 · 约 1 分钟
Linux--使用Snap安装第三方微信客户端Electronic-Wechat
前言 腾讯估计是不会给Linux系统开发任何软件了,不过问题不大。我们有很多好用的第三方软件替代~~(无奈之举,摊手)~~ 关于Snap Ubuntu官网上的介绍 Snaps are applications packaged with all their dependencies to run on all popular Linux distributions from a single bu
2025-10-27 · 系统配置 · 约 1 分钟
修改Linux系统的鼠标滚轮的速度
Linux默认的鼠标滚轮实在太慢了,总是让我有一种Linux很卡的错觉,而且还不像Windows那样可以直接修改所有程序中的鼠标滚轮速度,不过没事,可以用imwheel这个工具来修改~ 安装 Debian系: sudo apt install imwheel Arch: sudo pacman -S imwheel 配置 创建~/.imwheelrc文件 nano ~/.imwheelrc 编辑内
2025-10-27 · 系统配置 · 约 1 分钟
讨论
共 0 条加载评论中…