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.邮件别名

[[email protected] named]# vim /etc/aliases

97 admin:          root                          ##邮件别名

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

[[email protected] ~]# vim /etc/postfix/moreuser

user1

user2

[[email protected] ~]# systemctl restart postfix.service

mail -u 用户名

postsuper -d  删除排队邮件

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

postalias /etc/aliases

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

[[email protected] Desktop]$ yum install -y telnet

[[email protected] 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:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

250 2.1.5 Ok

data

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

qwdq

qwdeq

qeq

.

测试

[[email protected] ~]# 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 [email protected]       Tue May 23 09:53  15/494

& 2

Message  2:

From [email protected]  Tue May 23 09:53:48 2017

Return-Path: <[email protected]>

X-Original-To: [email protected]

Delivered-To: [email protected]

Status: R

qwdq

qwdeq

qeq

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

在mta上

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

[email protected] named]# vim /etc/postfix/main.cf

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

[email protected] named]# vim /etc/postfix/access

476 172.25.254.95 REJECT

[[email protected] named]# postmap /etc/postfix/access

[[email protected] named]# ls

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

dynamic  named.empty  named.loopback   slaves

[[email protected] named]# cd /etc/postfix

[[email protected] postfix]# ls

access     canonical  header_checks  master.cf  transport

access.db  generic    main.cf        relocated  virtual

测试

[[email protected] 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:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

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

##限制用户发送

[[email protected] postfix]# postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"

[[email protected] postfix]# vim /etc/postfix/main.cf

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

[[email protected] postfix]# vim /etc/postfix/sender

[email protected]    REJECT

[[email protected] postfix]# postmap /etc/postfix/sender

[[email protected] postfix]# ls

access     canonical  header_checks  master.cf  sender     transport

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

[[email protected] postfix]# systemctl restart postfix.service

测试

[[email protected] 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:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

554 5.7.1 <[email protected]>: Sender address rejected: Access denied

##限制用户接收

[[email protected] postfix]# postconf -e "smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recip"

[[email protected] postfix]# vim /etc/postfix/main.cf

smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recip

[[email protected] postfix]# vim /etc/postfix/recip

[email protected]    REJECT

[[email protected] postfix]# postmap /etc/postfix/recip

[[email protected] postfix]# systemctl restart postfix.service

测试

[[email protected] 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:[email protected]

250 2.1.0 Ok

rcpt to:[email protected]

554 5.7.1 <[email protected]>: Recipient address rejected: Access denied

#出站地址伪装

做好dns解析

[[email protected] named]#  postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"

[[email protected] named]# vim /etc/postfix/main.cf

smtp_generic_maps = hash:/etc/postfix/generic

[[email protected] named]#  vim /etc/postfix/generic

[email protected]           [email protected]

[[email protected] named]# postmap /etc/postfix/generic

[[email protected] named]# cd /etc/postfix/

[[email protected] postfix]# ls

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

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

[[email protected] postfix]# id westos

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

测试

From [email protected]  Tue May 23 11:55:08 2017

Return-Path: <[email protected]>

X-Original-To: [email protected]

Delivered-To: [email protected]

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

To: [email protected]

Subject: qdq

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

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

From: [email protected]

Status: R

##入站地址转换

做好dns解析

[[email protected] postfix]# postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

[[email protected] postfix]# vim /etc/postfix/virtual

295 [email protected]         [email protected]

[[email protected] postfix]# vim /etc/postfix/main.cf

virtual_alias_maps = hash:/etc/postfix/virtual

[[email protected] postfix]# postmap /etc/postfix/virtual

[[email protected] postfix]# systemctl restart postfix.service

[[email protected] postfix]# mail [email protected]

Subject: qwdq

qwdq

dq

wdq

.

EOT

测试

[[email protected] 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 [email protected]  Tue May 23 12:10:01 2017

Return-Path: <[email protected]>

X-Original-To: [email protected]

Delivered-To: [email protected]

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

To: [email protected]

Subject: qwdq

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

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

From: [email protected] (root)

Status: R

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

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

1.dovecot用来提供收件协议

pop3            110

imap            143

imaps           993

pop3s           995

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

2.yum intsall -y dovecot

3.

[[email protected] 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

[[email protected] named]# vim /etc/dovecot/conf.d/10-mail.conf

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

[[email protected] ~]# su westos

[[email protected] root]$ cd ~

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

[[email protected] ~]$ touch /home/westos/mail/.imap/INBOX

[[email protected] 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.

[[email protected] westos]# systemctl restart dovecot.service

[[email protected] ~]# mkdir /etc/skel/mail/.imap -p

[[email protected] ~]# touch /etc/skel/mail/.imap/INBOX

[[email protected] ~]# useradd zhang

[[email protected] ~]# 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.

[[email protected] ~]# systemctl restart dovecot.service

测试

主机安装mutt

[[email protected] Desktop]# mutt -f pop://[email protected]

安装雷鸟

用真机

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

接下来进行以下操作

进去之后进行登陆并且给[email protected]恢复邮件

测试

[[email protected] ~]# 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 [email protected]     Wed May 24 11:52  32/940   "Re:123"

& 2

Message  2:

From [email protected]  Wed May 24 11:52:52 2017

Return-Path: <[email protected]>

X-Original-To: [email protected]

Delivered-To: [email protected]

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

From: "[email protected]" <[email protected]>

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

31.2.0

To: root <[email protected]>

Subject: Re:123

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

Status: R

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

[[email protected] ~]# yum install -y httpd php php-mysql mariadb-server

[[email protected] ~]# systemctl start mariadb

[[email protected] ~]# vim /etc/my.cnf

[[email protected] ~]# systemctl restart postfix.service

[[email protected] ~]# systemctl restart mariadb.service

[[email protected] ~]# mysql_secure_installation

[[email protected] ~]# cd /var/www/html

[[email protected] html]# ls

phpMyAdmin-3.4.0-all-languages.tar.bz2

[[email protected] html]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2

[[email protected] html]# rm -fr *.bz2

[[email protected] html]# ls

phpMyAdmin-3.4.0-all-languages

[[email protected] html]# mv phpMyAdmin-3.4.0-all-languages/ myadmin

[[email protected] html]# ls

myadmin

[[email protected] html]# cd myadmin

[[email protected] myadmin]# cp config.sample.inc.php  config.inc.php

[[email protected] myadmin]# vim config.inc.php

[[email protected] myadmin]# systemctl restart httpd

[[email protected] 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 [email protected] identified by ‘postuser‘;

Query OK, 0 rows affected (0.00 sec)

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

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit

Bye

[[email protected] 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           |

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

| [email protected] | lee      | lee.com | /mnt/lee.com/lee/ |

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

[[email protected] ~]# cd /etc/postfix/

[[email protected] 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的查询条件

[[email protected] postfix]#  postmap -q "[email protected]" mysql:/etc/postfix/mailuser.cf

[email protected]

[[email protected] 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

[[email protected] postfix]#  postmap -q "lee.com" mysql:/etc/postfix/maildomain.cf

lee.com

[[email protected] 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

[[email protected] postfix]#  postmap -q "[email protected]" mysql:/etc/postfix/mailbox.cf

/mnt/lee.com/lee/

####配置postfix

[[email protected] ~]# groupadd -g 666 vmail

[[email protected] ~]# id vmail

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

[[email protected] ~]# postconf -d | grep virtual

[[email protected] ~]# postconf -e "virtual_mailbox_base = /home/vmail"

[[email protected] ~]# postconf -e "virtual_uid_maps = static:666"

[[email protected] ~]# postconf -e "virtual_gid_maps = static:666"

[[email protected] ~]# postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"

[[email protected] ~]# postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"

[[email protected] ~]# postconf -e "virtual_mailbox_domain = mysql:/etc/postfi/maildomain.cf"

systemctl restart postfix.service

测试

给[email protected]的邮件在/home/vmail/lee.com/new/里面可以找到

时间: 2024-11-07 21:30:37

postfix的相关文章

centos7.2下搭建postfix++dovecot+courier-authlib+extmail邮件收发系统

专业的事由专业的人去做,现在DNS,mail邮箱系统基本都是专业的公司去做了,越来越少公司自己搭建DNS,mail等系统服务 这次由于服务器要迁移,公司的邮箱系统一直都是用开源的postfix的,只能自己折腾 在此记录一下,搭建全过程使用root账号,中间有一些错误调试的,都给忽略了,这里只给出最的配置 在文章最后面会有一些错误调试的记录 不管遇到什么错误,首先打印日志来看! 不管遇到什么错误,首先打印日志来看! 不管遇到什么错误,首先打印日志来看! 在网上大概了解了一下整个邮箱系统的组成: #

/var/spool/postfix/maildrop 下有大量文件

参考链接:http://www.shangxueba.com/jingyan/121368.html /var/spool/postfix/maildrop  下有大量文件,怎么会有这么多的文件呢 在网上搜索之后明白是mail没有成功的邮件.由于linux在执行cron时,会将cron执行脚本中的output和warning信息,都会以邮件的形式发送cron所有者, 而我的服务器中关闭了postfix,导致邮件发送不成功,全部小文件堆积在了maildrop目录下面.如果sendmail或者pos

postfix邮件的配置 和 收发问题处理

  我司也是用postfix收发邮件.自建的邮箱有2个主要问题: 1.是否可以收发邮件正常. 2.垃圾邮件如何处理. 处理1: A. 网上的配置postfix main.cf已经很全了.复制一遍基本都可以了. B. 注意的地方是. 1.  MX的TXT记录是否有做.(A记录的TXT,IPv4的 TXT也是可以的,最好全做) spf.v1 mx:mail.x.com -all spf.v1 ipv4:x.x.x.x -all spf.v4 a:mail.x.com -all 2. IP PTR记录

Install postfix on Ubuntu 14.04.txt

Ubuntu 14.04上安装和配置Postfix邮件服务详细教程 Postfix: 用来接受和发送邮件的邮件服务器,正确说法应该叫邮件传送代理(Mail Transfer Agent,MTA),是邮件服务最重要的部分:    Dovecot: POP 和 IMAP 服务器,用来管理本地邮件目录以便用户能通过 Mail.app, Thunderbird, Mutt 等邮件客户端(又叫邮件用户代理 Mail User Agent, MUA)登陆和下载邮件:    Postgrey: 邮件灰名单工具

Postfix常用命令和邮件队列管理(queue)

本文主要介绍一下postfix的常用命令及邮件队列的管理: Postfix有以下四种邮件队列,均由管理队列的进程统一进行管理: maildrop:本地邮件放置在maildrop中,同时也被拷贝到incoming中. incoming:放置正在到达队列或管理进程尚未发现的邮件. active:放置队列管理进程已经打开了并正准备投递的邮件,该队列有长度的限制. deferred:放置不能被投递的邮件.可能是推迟发送的邮件 启动postfix /usr/sbin/postfix start 停止pos

运维学习之postfix邮件系统服务

postfix 一.postfix邮件服务 postfix提供smtp协议用来投递邮件 默认端口25 /var/log/maillog##服务日志 mail [email protected] Subject: hello hello world .#用"."来结束录入内容并发送 mailq##查看邮件队列 postqueue -f##重新处理邮件队列 默认情况下邮件端口只在127.0.0.1上开启 二.测试环境配置 安装dns服务 配置1912文件内容如下 把named.localh

Linux6.5部署Postfix邮件服务器

2-12-部署Postfix邮件服务器实现邮件的收发功能 试验环境: 服务端:xuegod63.cn       IP:192.168.1.63 部署Postfix+Dovecot Postfix:提供邮件发送功能,使用的协议:SMTP,端口:25 Dovecot:提供邮件接收功能,使用的协议:POP3.IMAP,端口:110,143 邮件通信协议 1.SMTP(SimpleMail Transfer Protocol,简单邮件传输协议):主要用于发送和传输邮件.SMTP协议使用的TCP端口为2

Postfix邮件系统安装与配置:Postfix,Cyrus-IMAP,Cyrus-sasl,Dovecot和SPF

最近发现邮件发送服务还是挺重要的.可能对于每天只有一百来封的邮件发送需求的个人博主来说,一个免费的邮箱提供的免费SMTP邮件发送服务就可以满足了,但是对于一些大型的网站.论坛和平台,每天的邮件发送量可以达到上万封以上,免费的邮件发送服务是不能满足需要了. 市场上已经有了不少的付费邮件发送服务,但是终归是第三方的邮件发送服务,在邮件发送方式.邮件内容等方面肯定要受到不少的限制.与其花大量的时间寻找更好的付费邮件服务,还不如自己动手利用VPS或者服务器搭建一个属于自己的邮件发送平台,搭建起来并不复杂

3-unit4 postfix+mysql

##########postfix+mariadb#######发送邮件 准备工作yum install httpd php php-mysql mariadb-server -y ##配置mysql config phpmyadminconfig mariadbmysql_secure_installationcreate dbcreate tablecreate usermessagecreate dbuser ##添加数据库用户,并给其授权 1.vim /etc/postfix/mailu

postfix , dovecot 配置

(一)postfix  配置 一 配置dns 1 yum install bind -y 2 systemctl start named 3 vim /etc/named.conf 内容: options { //      listen-on port 53 { 127.0.0.1; }; //      listen-on-v6 port 53 { ::1; }; directory       "/var/named"; dump-file       "/var/na