2019独角兽企业重金招聘Python工程师标准>>>

  1. 创建用户
    [root@ebs-51660 ~]# useradd admin 你的邮箱用户名
    [root@ebs-51660 ~]# echo "123456" | passwd admin --stdin
  2. 确认MX记录的添加是否生效
    [root@ebs-51660 ~]# host fshongling.com
    fshongling.com mail is handled by 10 mail.fshongling.com.
  3. 安装postfix
    [root@ebs-51660 ~]# yum install postfix
  4. 删除sendmail
    [root@ebs-51660 ~]# rpm -e sendmail
  5. 更改默认邮件传输代理
    [root@ebs-51660 sasl2]# alternatives --config mta
     选择    命令
    ----------------------------------------------- 
    *+ 1           /usr/sbin/sendmail.postfix
    按 Enter 来保存当前选择[+],或键入选择号码:1
  6. 查看postfix
    [root@ebs-51660 ~]# alternatives --display mta
  7. postfix主配置文件main.cf
    [root@ebs-51660 postfix]# vim /etc/postfix/main.cf
    a、myhostname = mail.fshongling.com  //76行,将等号后面的部分改写为本机主机名
    b、mydomain = fshongling.com   //82行,设置域名
    c、myorigin = $mydomain   //97行,把$myhostname改为$mydomain
    d、inet_interfaces = all  //112行,把后面的localhost改成all
    e、mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain // 163行,把前面的注释拿掉,并加一下$mydomain
    f、mynetworks = 192.168.0.0/24, 127.0.0.0/8  //263行,设置内网和本地IP
    g、local_recipient_maps =  //209行,把前面的注释拿掉。h、smtpd_banner = $myhostname ESMTP unknow //568行,把前面的注释拿掉,然后把$mail_name ($mail_version)改成unknow 
    h、//在main.cf文件的底部加上以下内容
    l、smtpd_sasl_auth_enable = yes     //使用SMTP认证
    m、broken_sasl_auth_clients = yes   //让不支持RFC2554的smtpclient也可以跟postfix做交互。  
    n、smtpd_sasl_local_domain = $myhostname  // 指定SMTP认证的本地域名
    o、smtpd_sasl_security_options = noanonymous //取消匿名登陆方式p、smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination //设定邮件中有关收件人部分的限制
    q、 smtpd_sasl_security_restrictions = permit_mynetworks, permit_sasl_authenticated,  reject_unauth_destination //设置允许范围
    r、message_size_limit = 15728640     //邮件大小 
    s、mailbox_transport=lmtp:unix:/var/lib/imap/socket/lmtp   //设置连接cyrus-imapd的路径
    完成后,使用/usr/sbin/postconf -n来检查配置是否正确
  8. 配置SELinux
    查看是否安装SELinux
    [root@ebs-51660 ~]# cat /etc/sysconfig/selinux
    #      This file controls the state of SELinux on the system.
    #      SELINUX= can take one of these three values:
    #      enforcing -SELinux security policy is enforced.
    #      permissive -SELinux prints warnings instead of enforcing.
    #      disabled -No SELinux policy is loaded.SELINUX=enforcing
    #      SELINUXTYPE= type of policy in use. Possible valuesare:
    #      targeted- Only targeted network daemons are protected.
    #      strict -Full SELinux protection.SELINUXTYPE=targeted

    安装SELinux
    [root@ebs-51660 ~]# yum install selinux-policy-targeted

    wget linuxmail.info/files/rhel6/postfixdovecotsasl.te

    checkmodule -M -m -o postfixdovecotsasl.mod postfixdovecotsasl.te

    semodule_package -o postfixdovecotsasl.pp -m postfixdovecotsasl.mod

    semodule -i postfixdovecotsasl.pp

  9. 安装 cyrus-sasl 软件包
    [root@ebs-51660 ~]# yum install cyrus-sasl*

    (A)使用/etc/shadow文件验证

    [root@ebs-51660 ~]# vi /etc/sysconfig/saslauthd

    MECH=shadow

    FLAGS=

    [root@ebs-51660 ~]# vi /etc/sasl2/smtpd.conf

    pwcheck_method: saslauthd

    mech_list: plain login

    (B)使用/etc/sasldb文件验证

    [root@ebs-51660 ~]# vi /etc/sysconfig/saslauthd

    #MECH=pam      #注释掉原文此行

    FLAGS=sasldb

    [root@ebs-51660 ~]# vi /etc/sasl2/smtpd.conf

    pwcheck_method: auxprop

    auxprop_plugin: sasldb

    mech_list: plain login

    [root@ebs-51660 ~]# saslpasswd2 -c admin -u kingmed.com

    按提示输入两次密码(不要与系统密码相同),首次操作会生成/etc/sasldb2文件。

    [root@ebs-51660 ~]# chgrp postfix /etc/sasldb2

    [root@ebs-51660 ~]# chmod 640 /etc/sasldb2

    启动saslauthd

    [root@ebs-51660 ~]#chkconfig saslauthd on

    [root@ebs-51660 ~]#service saslauthd start

    [root@ebs-51660 ~]# /usr/sbin/testsaslauthd -u admin -p '123456' #用系统密码测试

    0: NO "authentication failed"

    解决办法:

    [root@ebs-51660 ~]# setsebool -P allow_saslauthd_read_shadow 1

    如果还是不能成功,则看的main.cf文件配置是否有错

  10. 开放相关端口

    [root@ebs-51660 ~]# vi /etc/sysconfig/iptables

    -A INPUT -p tcp -m multiport --dports 25,80,110,143 -j ACCEPT

    [root@ebs-51660 ~]# service iptables restart

  11. 重启postfix
    [root@ebs-51660 ~]# chkconfig postfix on

    [root@ebs-51660 ~]# service postfix restart

  12. 检验配置是否正确
    postfix 提供了check命令,可以检查当前postfix 的配置是否有问题、文件和目录权限是否正确

    [root@ebs-51660 ~]# postfix check
    没有错误就说明没有问题

  13. 发送邮件测试
    echo 'test' | mail -s 'test' test@test.com

  14. Telnet登录验证

    新安装的centos系统是没有安装telnet的,需要自己安装

    检查是否安装[root@ebs-51660 ~]# rpm -qa telnet
    安装[root@ebs-51660 ~]# yum install -y telnet

    检查是否安装telent-server[root@ebs-51660 ~]# rpm -qa telnet-server
    安装[root@ebs-51660 ~]# yum install telnet-server

    这里是用虚拟用户即/etc/sasldb帐号,先取得用户名和密码的BASE64编码:
    [root@ebs-51660 sasl2]# printf "admin@fshongling.com" | openssl base64
    bGl1eXVodWlAa2luZ21lZC5jb20=

    [root@ebs-51660 sasl2]# printf "123456" | openssl base64
    bGl1eXVodWk=

    [root@ebs-51660 ~]# telnet localhost 25

    Trying 127.0.0.1...

    Connected to localhost.

    Escape character is '^]'.

    220 mail.kingmed.com ESMTP Postfix

    ehlo localhost

    250-mail.kingmed.com

    250-PIPELINING

    250-SIZE 10240000

    250-VRFY

    250-ETRN

    250-AUTH DIGEST-MD5 GSSAPI PLAIN CRAM-MD5 LOGIN

    250-ENHANCEDSTATUSCODES

    250-8BITMIME

    250 DSN

    auth login

    334 VXNlcm5hbWU6

    bGl1eXVodWlAa2luZ21lZC5jb20= #liuyuhui@kingmed.com的BASE64编码

    334 UGFzc3dvcmQ6

    bGl1eXVodWk= #密码liuyuhui的BASE64编码

    235 2.7.0 Authentication successful

    mail from:liuyuhui@kingmed.com

    250 2.1.0 Ok

    rcpt to:jiangtao@kingmed.com

    250 2.1.5 Ok

    data

    354 End data with . #回车后以点号(.)结束

    hello,how are you?

    250 2.0.0 Ok: queued as 934C83622

    quit

    221 2.0.0 Bye

    Connection closed by foreign host.

    来看下jiangtao用户家目录下是否有此邮件(注意queued as 934C83622):

    [root@mail ~]# cat /home/jiangtao/Maildir/new/1375283408.Vfd00I3696M538506.mail.kingmed.com

    Return-Path:

    X-Original-To: jiangtao@kingmed.com

    Delivered-To: jiangtao@kingmed.com

    Received: from localhost (localhost [127.0.0.1])

    (Authenticated sender: liuyuhui@kingmed.com)

    by mail.kingmed.com (Postfix) with ESMTPA id 934C83622

    for ; Wed, 31 Jul 2013 23:09:20 +0800 (CST)

    Message-Id: <20130731150940.934C83622@mail.kingmed.com>

    Date: Wed, 31 Jul 2013 23:09:20 +0800 (CST)

    From: liuyuhui@kingmed.com

    To: undisclosed-recipients:;

    hello,how are you?

    POP/ IMAP设置

    为了让用户能在本地机器下载邮件,必须在服务器安装设置POP或IMAP。Dovecot是适用CentOS Linux邮件系统有名的imap/pop服务器之一,它支持maildir和mbox格式。

  15. 安装dovecot
    [root@ebs-51660 ~]# yum -y install dovecot
    [root@ebs-51660 ~]# vim /etc/dovecot/dovecot.conf
           protocols = imap pop3 // 大概在20行的位置
           listen = * // 27行左右

    [root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-auth.conf
           disable_plaintext_auth = no // 9行,将yes改为no并去掉#号
           auth_mechanisms = plain login // 97行

    [root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-mail.conf
           mail_location = maildir:~/Maildir

    [root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-master.conf

    service auth {

    unix_listener auth-userdb {

    }

    unix_listener /var/spool/postfix/private/auth {

    mode = 0666

    user = postfix

    group = postfix

    }
    }

    [root@ebs-51660 ~]# vim /etc/dovecot/conf.d/10-ssl.conf
           ssl = no

    [root@ebs-51660 ~]# vim /etc/dovecot/conf.d/20-pop3.conf
           pop3_uidl_format = XuXv
           pop3_client_workarounds = outlook-no-nuls oe-ns-eoh

    配置完后使用dovecot -n查看所有配置。

    启动dovecot:

    [root@ebs-51660 ~]# chkconfig dovecot on

    [root@ebs-51660 ~]# service dovecot start

    现在你可以使用邮件客户端代理软件和系统用户及密码来连接我们的Dovecot服务器了。

    未完待续

    http://www.cnblogs.com/apexchu/p/4271264.html
    http://blog.chinaunix.net/uid-20362960-id-1699884.html
    http://my.oschina.net/u/2450048/blog/531171
    http://www.mamicode.com/info-detail-1162987.html
    http://blog.jjonline.cn/linux/185.html

转载于:https://my.oschina.net/u/2401265/blog/698578

postfix邮箱服务器安装和配置相关推荐

  1. SUS系统 postfix邮箱设置

    [SUS11SP1 以下版本] SUS服务器配置postfix邮箱比较简单,在SUS11SP1版本下,可以通过yast管理器,直接配置邮箱: 1 配置DNS信息 执行yast命令,进入"Ne ...

  2. postfix 邮箱设置及常见错误

    postfix 邮箱设置及常见错误 1.如果装了sendmail的话,先卸载了. yum remove sendmail 2.安装 Postfix yum install postfix 3.更改默认 ...

  3. CentOS6.5_64位系统下安装配置postfix邮件系统 启用并配置SMTP虚拟账户

    一.前言 继写下<PHP下利用PHPMailer配合QQ邮箱下的域名邮箱发送邮件>一文已有一年之久,随着时间的流逝,此文中的一些解决方案逐渐暴露出了一个限制性问题,也就是通过smtp连接Q ...

  4. linux7 postfix,CentOS7下搭建postfix邮箱服务器并实现extmail的web访问

    笔记内容:CentOS7下搭建postfix邮箱服务器并实现extmail的web访问 笔记日期:2017-11-20 闲来无事想着尝试使用postfix搭建一个邮箱服务器,我是边搭建边写这个笔记,搭 ...

  5. postfix 邮箱搭建

    Postfix 由wietse负责开发 目的是为了sendmail提供一个更好的替代产品. postfix在投递效率.稳定性.服务性能以及安全性方面相当出色.linux中邮箱服务,需要DNS+post ...

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

    最近发现邮件发送服务还是挺重要的.可能对于每天只有一百来封的邮件发送需求的个人博主来说,一个免费的邮箱提供的免费SMTP邮件发送服务就可以满足了,但是对于一些大型的网站.论坛和平台,每天的邮件发送量可 ...

  7. hpe服务器稳定性,hpe服务器安装与配置

    hpe服务器安装与配置 内容精选 换一换 Ceph集群可采用TaiShan服务器和x86服务器混合部署的方式和全TaiShan服务器的非混合部署方式.在混合部署场景下,三个Ceph节点中,两台为Tai ...

  8. FJ集团企业级邮件服务器——Exchange服务器安装与配置(边缘传输服务器)

    简单就是力量(power cloaked in simplicity)! Exchange边缘传输服务器角色通常部署在组织外围网络中,它能够最小化攻击面,还可以处理所有面向Internet的邮件流,为 ...

  9. 阿里云服务器安装并配置nginx代理转发请求

    阿里云服务器安装并配置nginx代理转发请求 下载nginx安装包,或者上传nginx安装包,此处我用的是Xmanager工具从本地上传了一个nginx安装包. 安装依赖库 yum -y instal ...

  10. wordpress之邮箱插件的配置

    wordpress之邮箱插件的配置 1 2 3 4 5 6 7 分步阅读 使用wordpress,大家都希望本站能发出"xxxx@你的域名.com"这样的邮件. 本文教你如何配置邮 ...

最新文章

  1. ACMMM2017 | 电子科大斩获最佳论文!中科院自动化所多媒体计算组获得IEEE期刊最佳论文!
  2. anaconda -spyder报错解决-UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 611: illegal
  3. Java 多线程使用
  4. springboot搭建的ssm项目
  5. C#线程 在某一时间内,只有N个线程在并发执行,其余都在队列中的实现(转载)...
  6. python模块导入_python模块导入
  7. Ubuntu配置Typora和picgo
  8. PC/UVA 110405/10026 Shoemaker's problem
  9. SpringMVC路径配置
  10. svn 服务器端密码修改,svn服务器端设置密码
  11. 前端实现人员关系图谱
  12. 【每日AI】什么是机器学习(ML)?
  13. vue路由变化时使用axios取消所有请求
  14. 记一次android设备通过tun0网络连接上级国标平台问题
  15. 【Flutter实战静态页面】--在线点餐app(7)——页面跳转
  16. Era of nostalgia?(怀旧时代的到来?)
  17. Redis高可用——主从复制、哨兵模式、集群
  18. 《随机过程》学习笔记--高斯过程(1)
  19. 使用vue做一个“淘宝“项目(显示页面)
  20. 百度网盘资源怎么分享群链接下载?

热门文章

  1. UE4UMG系统入门
  2. python量化交易策略实例_实践《Python与量化投资从基础到实战》PDF代码+《量化交易之路用Python做股票量化分析》PDF代码解释...
  3. 理解LaaS、SaaS、PaaS的含义及区别
  4. Linux-下往移动硬盘中拷贝数据
  5. 【修真院PM小课堂】什么是三种环境?
  6. 树莓派如何接硬盘_树莓派添加USB外接硬盘
  7. 华为HCNA笔记-TO-BE-CONTINUED
  8. 用免费建站系统做一个专业的企业网站才靠谱!
  9. CTF-隐写术(三)
  10. 微信输入法,终于来了。。。