大网数据广告活动
服务器运维问答

Postfix block local domain from sending

· 52CE 我爱测

I have a centos 6.5 server running apache and hosting about 8 domains. There is also postfix 2.6 installed serving these local domains to send emails generated by php (website contact forms). Postfix installation is default. No m…

问题原文

原帖链接 · Theo Orphanos · CC BY-SA 3.0

I have a centos 6.5 server running apache and hosting about 8 domains. There is also postfix 2.6 installed serving these local domains to send emails generated by php (website contact forms). Postfix installation is default. No modifications have been made to main.cf or any other file.

Now, one of the websites has been hacked and is sending spam emails using addresses such as: random_user1@hacked_domain.com, random_user2@hacked_domain.com, random_user3@hacked_domain.com (hacked_domain.com is the actual domain name of the hacked website)

I want to block this particular (local) domain from sending, while all other domains sould send normally. So far, I have created a "blacklist" which I saved in postfix folder named "rbl_blacklist" and looks like that:

hacked_domain.com    REJECT

How can I use this file in main.cf in order to prevent messages from ***@hacked_domain.com from being sent?

(also, any other suggestions are welcome)

EDIT:

I do not want to block certain users, since there aren't any! I just want to block all email messages that are sent from: *@hacked_domain.com from being sent!

已采纳解答

原帖链接 · Theo Orphanos · CC BY-SA 3.0

The solution was "header_checks"

In main.cf comment out any "header_checks" lines -if exist and then add:

header_checks = pcre:/etc/postfix/header_checks.pcre

Create header_checks.pcre file (at the postfix folder)

# cd /etc/postfix
# vi header_checks.pcre

inside header_checks.pcre file added the following line:

/^From:((?![^@]*?user1|[^@]*?user2|[^@]*?user3|[^@]*?webmaster)[^@]*?)@hacked_domain\.com/ DISCARD

(we allow only user1, user2, user3 and webmaster to send emails -the other addresses get discarded!)

# service postfix restart

...and worked!

Hope that helps others with similar issues!

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。