我的编程空间,编程开发者的网络收藏夹
学习永远不晚

postfix

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

postfix

   

#################postfix###################

1.postfix提供smtp协议用来投递邮件

默认端口 25

默认发布目录 /var/log/maillog          ##服务日志

mail root @.....      发邮件

主题:   

内容....

.

mailq                  ###查看邮件队列

postqueue -f           ###重新处理邮件队列

 

默认情况下邮件端口只在127.0.0.1上开启

 

2.

配置

vim /etc/postfix/main.cf

76 myhostname = westos-mail.westos.com   ###25端口开启的网络借口

83 mydomain = westos.com                 ###指定mta的域名

99 myorigin = westos.com                 ###制定邮件来源结尾(@后面的字符内容)

116 inet_interfaces = all                ###25端口开启的网络借口

164 mydestination = $myhostname, $mydomain, localhost     ###接受邮件字符的指定

systemctl restart postfix.service

systemctl stop firewalld

 

3.邮件别名

[root@westos-mail named]# vim /etc/aliases

    97 admin:          root                          ##邮件别名

    98 moreuser:       :include:/etc/postfix/moreuser    ##邮件群发

 

[root@qq-mail ~]# vim /etc/postfix/moreuser

   user1

   user2

[root@qq-mail ~]# systemctl restart postfix.service

mail -u 用户名

postsuper -d  删除排队邮件

postqueue -f  重新发送排队的邮件

postalias /etc/aliases

 

 

 

4.通过远程主机发送邮件

[kiosk@foundation75 Desktop]$ yum install -y telnet

[root@foundation75 Desktop]# telnet 172.25.254.101 25

Trying 172.25.254.101...

Connected to 172.25.254.101.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

ehlo hello

250-westos-mail.westos.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:root@westos.com

250 2.1.0 Ok

rcpt to:root@qq.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

qwdq

qwdeq

qeq

.

测试

[root@qq-mail ~]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 2 messages 1 new 2 unread

 U  1 root                  Tue May 23 09:45  25/739   "qq"

>N  2 root@westos.com       Tue May 23 09:53  15/494   

& 2

Message  2:

From root@westos.com  Tue May 23 09:53:48 2017

Return-Path: <root@westos.com>

X-Original-To: root@qq.com

Delivered-To: root@qq.com

Status: R

 

qwdq

qwdeq

qeq

 

5.邮件客户端的访问控制

在mta上

postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"

root@westos-mail named]# vim /etc/postfix/main.cf

 681 smtpd_client_restrictions = check_client_access hash:/etc/postfix/acce    ss

root@westos-mail named]# vim /etc/postfix/access

  476 172.25.254.95 REJECT

[root@westos-mail named]# postmap /etc/postfix/access

[root@westos-mail named]# ls

data     named.ca     named.localhost  qq.com.zone  westos.com.zone

dynamic  named.empty  named.loopback   slaves

[root@westos-mail named]# cd /etc/postfix

[root@westos-mail postfix]# ls

access     canonical  header_checks  master.cf  transport

access.db  generic    main.cf        relocated  virtual

测试

[root@test Desktop]# telnet 172.25.254.195 25

Trying 172.25.254.195...

Connected to 172.25.254.195.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

mail from:root@westos.com           

250 2.1.0 Ok

rcpt to:root@qq.com

554 5.7.1 <unknown[172.25.254.95]>: Client host rejected: Access denied

##限制用户发送

[root@westos-mail postfix]# postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"

[root@westos-mail postfix]# vim /etc/postfix/main.cf

  681 smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender

[root@westos-mail postfix]# vim /etc/postfix/sender

   student@westos.com    REJECT

[root@westos-mail postfix]# postmap /etc/postfix/sender

[root@westos-mail postfix]# ls

access     canonical  header_checks  master.cf  sender     transport

access.db  generic    main.cf        relocated  sender.db  virtual

[root@westos-mail postfix]# systemctl restart postfix.service

测试

[root@foundation75 Desktop]# telnet 172.25.254.101 25

Trying 172.25.254.101...

Connected to 172.25.254.101.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

mail from:student@westos.com

250 2.1.0 Ok

rcpt to:root@westos.com

554 5.7.1 <student@westos.com>: Sender address rejected: Access denied

##限制用户接收

[root@westos-mail postfix]# postconf -e "smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recip"

[root@westos-mail postfix]# vim /etc/postfix/main.cf

  smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recip

[root@westos-mail postfix]# vim /etc/postfix/recip

  westos@westos.com    REJECT

[root@westos-mail postfix]# postmap /etc/postfix/recip

[root@westos-mail postfix]# systemctl restart postfix.service

测试

[root@foundation75 Desktop]# telnet 172.25.254.101 25

Trying 172.25.254.101...

Connected to 172.25.254.101.

Escape character is '^]'.

220 westos-mail.westos.com ESMTP Postfix

mail from:root@qq.com

250 2.1.0 Ok

rcpt to:westos@westos.com

554 5.7.1 <westos@westos.com>: Recipient address rejected: Access denied

#出站地址伪装

做好dns解析

[root@westos-mail named]#  postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"

[root@westos-mail named]# vim /etc/postfix/main.cf

  smtp_generic_maps = hash:/etc/postfix/generic

[root@westos-mail named]#  vim /etc/postfix/generic

  westos@westos.com           hello@sb.com

[root@westos-mail named]# postmap /etc/postfix/generic

[root@westos-mail named]# cd /etc/postfix/

[root@westos-mail postfix]# ls

access     canonical  generic.db     main.cf    recip     relocated  sender.db  virtual

access.db  generic    header_checks  master.cf  recip.db  sender     transport

[root@westos-mail postfix]# id westos

uid=1001(westos) gid=1001(westos) groups=1001(westos)

测试

From hello@sb.com  Tue May 23 11:55:08 2017

Return-Path: <hello@sb.com>

X-Original-To: root@qq.com

Delivered-To: root@qq.com

Date: Tue, 23 May 2017 11:55:08 -0400

To: root@qq.com

Subject: qdq

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: hello@sb.com

Status: R

##入站地址转换

做好dns解析

[root@westos-mail postfix]# postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

[root@westos-mail postfix]# vim /etc/postfix/virtual

   295 hello@sb.com         westos@westos.com

[root@westos-mail postfix]# vim /etc/postfix/main.cf

  virtual_alias_maps = hash:/etc/postfix/virtual

[root@westos-mail postfix]# postmap /etc/postfix/virtual

[root@westos-mail postfix]# systemctl restart postfix.service

[root@westos-mail postfix]# mail hello@sb.com

Subject: qwdq

qwdq

dq

wdq

.

EOT

测试

[root@westos-mail postfix]# mail -u westos

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/mail/westos": 1 message 1 new

>N  1 root                  Tue May 23 12:10  20/560   "qwdq"

& 1

Message  1:

From root@westos.com  Tue May 23 12:10:01 2017

Return-Path: <root@westos.com>

X-Original-To: hello@sb.com

Delivered-To: westos@westos.com

Date: Tue, 23 May 2017 12:10:00 -0400

To: hello@sb.com

Subject: qwdq

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: root@westos.com (root)

Status: R

######################################

###########dovecot####################

1.dovecot用来提供收件协议

pop3            110

imap            143

imaps           993    

pop3s           995

给定用户名称,用户密码,dovecot程序代替我们去看这个用户的邮件文件

 

2.yum intsall -y dovecot

3.

[root@westos-mail named]# vim /etc/dovecot/dovecot.conf

 24 protocols = imap pop3 lmtp

 48 login_trusted_networks = 0.0.0.0/0

 49 disable_plaintext_auth = no

 

[root@westos-mail named]# vim /etc/dovecot/conf.d/10-mail.conf

   30 mail_location = mbox:~/mail:INBOX=/var/mail/%u

[root@westos-mail ~]# su westos

[westos@westos-mail root]$ cd ~

[westos@westos-mail ~]$ mkdir /home/westos/mail/.imap -p

[westos@westos-mail ~]$ touch /home/westos/mail/.imap/INBOX

[root@westos-mail westos]# passwd westos

Changing password for user westos.

New password:

BAD PASSWORD: The password is a palindrome

Retype new password:

passwd: all authentication tokens updated successfully.

[root@westos-mail westos]# systemctl restart dovecot.service

[root@westos-mail ~]# mkdir /etc/skel/mail/.imap -p

[root@westos-mail ~]# touch /etc/skel/mail/.imap/INBOX

[root@westos-mail ~]# useradd zhang

[root@westos-mail ~]# passwd zhang

Changing password for user zhang.

New password:

BAD PASSWORD: The password is a palindrome

Retype new password:

passwd: all authentication tokens updated successfully.

[root@westos-mail ~]# systemctl restart dovecot.service

测试

主机安装mutt

[root@foundation75 Desktop]# mutt -f pop://zhang@172.25.254.101

安装雷鸟

用真机

rpm -ivh thunderbird-31.2.0-1.el7.x86_64.rpm

接下来进行以下操作

 postfix

 

进去之后进行登陆并且给westos@westom.com恢复邮件

测试

[root@westos-mail ~]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 2 messages 1 new

    1 root                  Tue May 23 11:22  21/572   "qwew"

>N  2 westos@westos.com     Wed May 24 11:52  32/940   "Re:123"

& 2

Message  2:

From westos@westos.com  Wed May 24 11:52:52 2017

Return-Path: <westos@westos.com>

X-Original-To: root@westos.com

Delivered-To: root@westos.com

Date: Wed, 24 May 2017 23:52:52 +0800

From: "westos@westos.com" <westos@westos.com>

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/

31.2.0

To: root <root@westos.com>

Subject: Re:123

Content-Type: text/plain; charset=UTF-8; format=flowed

Status: R

 

 

################postfix+mariadb##############

 

[root@westos-mail ~]# yum install -y httpd php php-mysql mariadb-server

[root@westos-mail ~]# systemctl start mariadb

[root@westos-mail ~]# vim /etc/my.cnf

[root@westos-mail ~]# systemctl restart postfix.service

[root@westos-mail ~]# systemctl restart mariadb.service

[root@westos-mail ~]# mysql_secure_installation

[root@westos-mail ~]# cd /var/www/html

[root@westos-mail html]# ls

phpMyAdmin-3.4.0-all-languages.tar.bz2

[root@westos-mail html]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2

[root@westos-mail html]# rm -fr *.bz2

[root@westos-mail html]# ls

phpMyAdmin-3.4.0-all-languages

[root@westos-mail html]# mv phpMyAdmin-3.4.0-all-languages/ myadmin

[root@westos-mail html]# ls

myadmin

[root@westos-mail html]# cd myadmin

[root@westos-mail myadmin]# cp config.sample.inc.php  config.inc.php

[root@westos-mail myadmin]# vim config.inc.php

[root@westos-mail myadmin]# systemctl restart httpd

[root@westos-mail myadmin]# mysql -uroot -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 32

Server version: 5.5.35-MariaDB MariaDB Server

 

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> create user postuser@localhost identified by 'postuser';

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> grant select,update,insert on email.* to postuser@localhost;

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> quit

Bye

[root@westos-mail myadmin]# mysql -upostuser -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 33

Server version: 5.5.35-MariaDB MariaDB Server

 

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MariaDB [(none)]> select * from email.emailuser;

+-------------+----------+---------+-------------------+

| username    | password | domain  | maildir           |

+-------------+----------+---------+-------------------+

| lee@lee.com | lee      | lee.com | /mnt/lee.com/lee/ |

+-------------+----------+---------+-------------------+

[root@westos-mail ~]# cd /etc/postfix/

[root@westos-mail postfix]# vim mailuser.cf            ####用户名查询

 1 hosts = localhost                 ##数据库所在的主机

  2 user = postuser                  ##登陆数据库的用户

  3 password = postuser              ##登陆数据库的密码

  4 dbname = email                   ##postfix要查询的名称

  5 table = emailuser                ##postfix要查询表的名称

  6 select_field = username          ##postfix要查询的字段

  7 where_field = username           ##用户给定postfix的查询条件

[root@westos-mail postfix]#  postmap -q "lee@lee.com" mysql:/etc/postfix/mailuser.cf

lee@lee.com

[root@westos-mail postfix]# vim maildomain.cf       ####用户域名查询

 1 hosts = localhost

  2 user = postuser

  3 password = postuser

  4 dbname = email

  5 table = emailuser

  6 select_field = domain

  7 where_field = domain

[root@westos-mail postfix]#  postmap -q "lee.com" mysql:/etc/postfix/maildomain.cf

lee.com

[root@westos-mail postfix]# vim mailbox.cf       ####用户邮箱位置查询

 1 hosts = localhost

  2 user = postuser

  3 password = postuser

  4 dbname = email

  5 table = emailuser

  6 select_field = maildir

  7 where_field = username

 

[root@westos-mail postfix]#  postmap -q "lee@lee.com" mysql:/etc/postfix/mailbox.cf

/mnt/lee.com/lee/

 附图

postfix

postfix

postfix

postfix

postfix


####配置postfix

[root@westos-mail ~]# groupadd -g 666 vmail

[root@westos-mail ~]# id vmail

uid=666(vmail) gid=666(vmail) groups=666(vmail)

[root@westos-mail ~]# postconf -d | grep virtual

[root@westos-mail ~]# postconf -e "virtual_mailbox_base = /home/vmail"

[root@westos-mail ~]# postconf -e "virtual_uid_maps = static:666"

[root@westos-mail ~]# postconf -e "virtual_gid_maps = static:666"

[root@westos-mail ~]# postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"

[root@westos-mail ~]# postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"

[root@westos-mail ~]# postconf -e "virtual_mailbox_domain = mysql:/etc/postfi/maildomain.cf"

systemctl restart postfix.service

测试

给lee@lee.com的邮件在/home/vmail/lee.com/new/里面可以找到


附图

postfix

postfix



免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

postfix

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

2024-04-02

RHEL5+Postfix+MySql+

八、为postfix开启基于cyrus-sasl的认证功能 使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的:# /usr/local/postfix/sbin/postconf  -a
2023-01-31

postfix+pop3+imap+cy

1.安装postfix软件包2.安装smtp认证包3.安装pop3和imap服务包4.安装webmail软件包(webmail需要web服务器的支持)MicrosoftInternetExplorer402DocumentNotSpecif
2023-01-31

linux 安装配置 postfix+p

首先介绍下环境与提前准备。            postfix      192.168.6.121    1.在自己的域名服务商添加 域名 与A记录,我的是内部测试也就在自己的内部DNS 上添加了 以下记录               
2023-01-31

postfix之使用smtps、pop3

使用smtps:    smtp  25 --> smpts 465    S/MIME (Security MIME)        USER <--> USER        2个用户之间实现邮件传输,每个用户都有独立的证书,证书是由2
2023-01-31

Linux中如何安装postfix

这篇文章主要介绍Linux中如何安装postfix,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!安装postfixpostfix是一个快速、易于管理、安全性高的邮件发送服务,可以配合dovecot实现一个完美的邮箱服
2023-06-05

CentOS6中怎么安装postfix

今天小编给大家分享一下CentOS6中怎么安装postfix的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。Postfix 是
2023-06-27

Postfix邮件原理是什么

今天小编给大家分享一下Postfix邮件原理是什么的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。postfix是Wietse
2023-06-28

Postfix对邮件如何处理

小编给大家分享一下Postfix对邮件如何处理,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!一. 接收邮件的过程当postfix接收到一封新邮件时,新邮件***在
2023-06-16

postfix安装以及配置3

邮件服务器系统的smtp服务器,在邮件服务器系统中充当MTA角色1 安装Postfix(1)   创建相关的用户和组否则make install得时候会报错#groupadd postfix -g 501#groupadd postdrop
2023-01-31

CentOS postfix的安装创建方法

这篇文章主要介绍“CentOS postfix的安装创建方法”,在日常操作中,相信很多人在CentOS postfix的安装创建方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CentOS postfix的
2023-06-16

Linux中如何配置Postfix邮件发送

今天小编给大家分享一下Linux中如何配置Postfix邮件发送的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。部署DNS服务
2023-06-28

Linux下怎么安装部署Postfix

本篇内容主要讲解“Linux下怎么安装部署Postfix”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Linux下怎么安装部署Postfix”吧!部署DNS服务器postfix根据域名和地址做一
2023-06-27

Linux下如何安装Postfix邮件

这篇文章主要介绍Linux下如何安装Postfix邮件,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!本套邮件系统的搭建,从如何发邮件到收邮件到认证到虚拟用户虚拟域以及反病毒和反垃圾邮件等都有详细的介绍。在搭建过程中必
2023-06-27

Linux中Postfix邮件原理分析

这篇文章将为大家详细讲解有关Linux中Postfix邮件原理分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。邮件相关协议SMTP(Simple Mail Transfer Protocol)即简单邮件
2023-06-27

详解/etc/postfix下 main.cf 配置文件

postconf -n#别名数据库(postalias/newaliases 命令生成) alias_database = hash:/etc/postfix/aliases #别名表,列出local mda 所使用的别名数据库 ali
2022-06-04

编程热搜

目录