热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

gentoo系统中安装配置sendmail邮件服务器和dovecot收件器

先说需要安装哪些软件,因为使用的平台是Gentoo操作系统,所以就用gentoo的安装方式1:安装dns域名服务器,如果你在公网,并且有自已的域名,那么不用自已安装域名服务器,(因为邮件服务器要用到域名的解析,反向解析,所以要安装,我尝试用ip地址代替邮
先说需要安装哪些软件,因为使用的平台是Gentoo 操作系统,所以就用gentoo 的安装方式

1安装dns 域名服务器,如果你在公网,并且有自已的域名,那么不用自已安装域名服务器,( 因为邮件服务器要用到域名的解析,反向解析,所以要安装,我尝试用ip 地址代替邮箱域名,失败,所以必须装)
emerge bind bind-tools     版本没要求,默认就行
2安装sendmail
 USE='' mbox  ssl"   emerge  sendmail   
要加上mbox ssl 两个标记,以便让sendmail 支持mbox的邮件存储方式(就是在/var/mail 目录上存不同用户的邮件,而不是在各个用户的~目录下,) 另外还有一个sasl 的标记,不加也可以,好像sendmail 从某个版本对于ssl 的支持不需要sasl 了, 当前的sendmail 是mail-mta/sendmail-8.14.4
3 要用到openssl 库,在进行安全的ssl 连接时,需要用它生成几个文件,好像是证书之类,不太懂,但得装上
emerge -av openssl
4 安装dovecot
USE="ssl   maildir mbox" emerge dovecot  
确保ssl maildir mbox 这几个标记的存在,
sendmail 只负责发邮件,要想收邮件,要用到dovecot

下面是具体的安装过程

一安装并配置bind
sendmail 要用到域名解析,反向域名解析,所以要选安装dns 服务器bind,安装方法及配置见
http://blog.csdn.net/jixiuffff/archive/2009/11/07/4782285.aspx
简要摘写如下
/etc/bind/named.conf
options {
        directory "/var/bind";
        // uncomment the following lines to turn on DNS forwarding,
        // and change the forwarding ip address(es) :
        //forward first;
        //forwarders {
        //      123.123.123.123;
        //      123.123.123.123;
        //};
        listen-on-v6 { none; };
// 注释掉这行
//       listen-on { 127.0.0.1; };
//       listen-on { 127.0.0.1;192.168.1.2; };
        // to allow only specific hosts to use the DNS server:
        //allow-query {
        //      127.0.0.1;
        //};
        // if you have problems and are behind a firewall:
        //query-source address * port 53;
        pid-file "/var/run/named/named.pid";
};
// Briefly, a zone which has been declared delegation-only will be effectively
// limited to containing NS RRs for subdomains, but no actual data beyond its
// own apex (for example, its SOA RR and apex NS RRset). This can be used to
// filter out "wildcard" or "synthesized" data from NAT boxes or from
// authoritative name servers whose undelegated (in-zone) data is of no
// interest.
// See http://www.isc.org/products/BIND/delegation-only.html for more info
//zone "COM" { type delegation-only; };
//zone "NET" { type delegation-only; };
zone "." IN {
        type hint;
        file "named.cache";
};
zone "localhost" IN {
        type master;
        file "pri/localhost.zone";
        allow-update { none; };
        notify no;
};
zone "127.in-addr.arpa" IN {
        type master;
        file "pri/127.zone";
        allow-update { none; };
        notify no;
};
//vi /etc/conf.d/hostname
//hostname="jixiuf.org"
//主机名为jixiuf.org
//我的ip是192.168.1.2 ,
//pri/jixiuf.org.zone 是/etc/bin/pri/jixiuf.org.zone
//实际是/var/bind/pri/目录的一个软链接
//此文件进行正向域名解析 ,由域名得ip
zone "jixiuf.org" IN {
        type master;
        file "pri/jixiuf.org.zone";
        allow-update { none; };
        notify no;
};
//此文件进行反向域名解析,由ip 得域名
zone "192.in-addr.arpa" IN {
    type master;
    file "pri/jixiuf_r.zone";
    allow-update { none; };
    notify no;
};
# Use with the following in named.conf, adjusting the allow list as neede
# key "rndc-key" {
#       algorithm hmac-md5;
#       secret "kGKuKdPDjzvUPgJPncVZxw==";
# };
#
# controls {
#       inet 127.0.0.1 port 953
#               allow { 127.0.0.1; } keys { "rndc-key"; };
# };
# End of named.conf

jf pri # cat   /var/bind/pri/jixiuf.org.zone
jixiuf.org 的正向解析文件
$TTL 1W
@       IN      SOA  jixiuf.org.    root.jixiuf.org.  (
                                      2010092203 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      604800     ; Expire - 1 week
                                      86400 )    ; Minimum
@               IN      NS      jixiuf.org.
@               IN      A       192.168.1.2
;三个别名mail.jixiuf.org.    smtp.jixiuf.org. pop3.jixiuf.org.  实际上都是jixiuf.org.的别名,它们具有相同的ip 192.168.1.2
mail            IN      CNAME   jixiuf.org.
smtp            IN      CNAME   jixiuf.org.
pop3            IN      CNAME   jixiuf.org.
@               IN      MX 5       mail.jixiuf.org.

/var/bind/pri/localhost.zone  ,默认即可
反向解析文件
jf pri # cat   /var/bind/pri/jixiuf_r.zone
$ORIGIN 192.in-addr.arpa.
$TTL 1W
@                       1D IN SOA       jixiuf.org. root.jixiuf.org. (
                                        2010092204      ; serial
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
; @ 在这里相当于 jixiuf
@                         1D IN NS           jixiuf.org.
;192.168.1.2 解析为jixiuf.org.  及mail.jixiuf.org. ....
2.1.168                         1D IN PTR          jixiuf.org.
2.1.168                         1D IN PTR          mail.jixiuf.org.
2.1.168                         1D IN PTR          smtp.jixiuf.org.
2.1.168                         1D IN PTR          pop3.jixiuf.org.

测试一下是否成功
正向解析
jixiuf pri # host smtp.jixiuf.org
smtp.jixiuf.org is an alias for jixiuf.org.
jixiuf.org has address 192.168.1.2
jixiuf.org mail is handled by 5 mail.jixiuf.org.
jixiuf pri # host pop3.jixiuf.org
pop3.jixiuf.org is an alias for jixiuf.org.
jixiuf.org has address 192.168.1.2
jixiuf.org mail is handled by 5 mail.jixiuf.org.
jixiuf pri # host mail.jixiuf.org
mail.jixiuf.org is an alias for jixiuf.org.
jixiuf.org has address 192.168.1.2
jixiuf.org mail is handled by 5 mail.jixiuf.org.
jixiuf pri # host jixiuf.org
jixiuf.org has address 192.168.1.2
jixiuf.org mail is handled by 5 mail.jixiuf.org.
反向解析 jixiuf pri # nslookup  192.168.1.2
Server:        127.0.0.1
Address:    127.0.0.1#53
2.1.168.192.in-addr.arpa    name = pop3.jixiuf.org.
2.1.168.192.in-addr.arpa    name = jixiuf.org.
2.1.168.192.in-addr.arpa    name = mail.jixiuf.org.
2.1.168.192.in-addr.arpa    name = smtp.jixiuf.org.
jixiuf pri #
========================================================================================================== 下面是关于sendmail 的了
1 添加两个测试用户
useradd -m -g mail -s /bin/false mail1
useradd       -g mail -s /bin/false mail2
passwd mail1
passwd mail2
mail1 有/home/mail1 目录,而mail2 没有
为mail1 mail2 起个别名, 不起也可以
/etc/mail/aliases
zhang3:  mail1
li4:     mail2
manager:  mail1, mail2
# zhang3@jixiuf.org means mail1@jixiuf.org
#and mail send to manager@jixiuf.org will be send to mail1@jixiuf.org and mail@jixiuf.org

然后运行命令newaliases
编辑 /etc/mail/access
127.0.0.1            RELAY
#192.168.1.2         RELAY
mail.jixiuf.org      RELAY
jixiuf.org           RELAY

然后运行 makemap  hash 表示发送到jixiuf.org mail.jixiuf.org 地址的信才给传送,其他地址的不送
/etc/init.d/sendmail start
此时sendmail 已经可以发信了,但是不能向外网关邮件,因为外网的邮箱服务器无法以我们的ip进行域名反解析(好像是,不太清楚)
在同一网段找另外一台机器,当然用虚拟机也可以(网络桥接)用Outlook Express  发mail1@jixiuf.org   manager@jixiuf.org  发送邮件 ,
smtp pop3 服务器都填写成mail.jixiuf.org 或者jixiuf.org 也可以
但是此时sendmail 发信不支持ssl 连接,所以用户名密码很容易被人监听到
下面进行sendmail 发件通过ssl
在/etc/mail/sendmail.mc 中添加
TRUST_AUTH_MECH("EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN")dnl
define(`confAUTH_MECHANISMS', `EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN GSSAPI KERBEROS_V4')dnl
dnl define(`CERT_DIR', `MAIL_SETTINGS_DIR`'certs')dnl
define(`CERT_DIR', `/etc/mail/certs')dnl
define(`confCACERT_PATH', `CERT_DIR')dnl
define(`confCACERT', `CERT_DIR/cacert.pem')dnl      1
define(`confSERVER_CERT', `CERT_DIR/cert.pem')dnl   2
define(`confSERVER_KEY', `CERT_DIR/key.pem')dnl     3
define(`confCLIENT_CERT', `CERT_DIR/cert.pem')dnl
define(`confCLIENT_KEY', `CERT_DIR/key.pem')dnl

然后运行
m4 sendmail.mc  >sendmail.cf  
接下来需要生成证书  这个过程不必理解,
生成的过程
http://www.worldhello.net/doc/email_howto/ar01s01s09.html
 从这篇文章的 1.9.7. 配置 sendmail — 证书管理 做就可以
摘录如下:
$ mkdir /tmp/CA
$ cd /tmp/CA
$ mkdir certs crl newcerts private
$ echo "01" > serial
$ cp /dev/null index.txt
$ cp /usr/local/openssl/openssl.cnf.sample openssl.cnf
    改成cp /etc/ssl/openssl.cnf   openssl.cnf
$ vi openssl.cnf   (set values)       这一步主要修改openssl.cnf 文件中
dir             = ./demoCA              # Where everything is kept
改成
dir             = /tmp/CA              #修改成我们实际的目录
$ openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -days 365 -config openssl.cnf
$ openssl req -nodes -new -x509 -keyout newreq.pem -out newreq.pem -days 365 -config openssl.cnf
$ openssl x509 -x509toreq -in newreq.pem -signkey newreq.pem -out tmp.pem
$ openssl ca -config openssl.cnf -policy policy_anything -out newcert.pem -infiles tmp.pem
$ rm -f tmp.pem
手动修改生成的 newreq.pem文件
Remove the unsigned certificate (leaving the private key 删除证书部分,只保留私钥部分
mkdir /etc/mail/certs
cp cacert.pem   /etc/mail/certs/cacert.pem
cp newreq.pem   /etc/mail/certs/key.pem
cp newcert.pem  /etc/mail/certs/cert.pem
cd /etc/mail/certs/
chmod 400 key.pem
Check key properties
$ openssl x509 -noout -in cacert.pem -text
Make sure that the CN of the CA certificate and CN of the server
certificate are different, because newer versions of Mozilla and
Netscape won't accept the server certificate if it is self-signed
这句不理解,
/etc/init.d/sendmail restart
现在可以通过安全的ssl 进行认证了.

关于sendmail ssl tls 配置两篇不错的文章
http://www.cromwell-intl.com/unix/sendmail-ssl.html
http://www.worldhello.net/doc/email_howto/ar01s01s09.html
====================================================================================================
下面是关于收邮件的   dovecot-1.2.11 ,用到这个软件,安装在上面提过,下面说配置
cd /etc/dovecot/
修改dovecot.conf
添加
protocols = imap imaps pop3 pop3s
listen = *
disable_plaintext_auth = no
log_path = /var/log/mail/err
info_log_path = /var/log/mail/info
ssl = no
#mail_location = mbox:~/mail:INBOX=/var/mail/%u  ,这个指定邮件在什么位置,以便比那儿存取,

/etc/init.d/dovecot/start
此时可以收邮件,但是没使用ssl 不安全
protocols = imap imaps pop3 pop3s
listen = *
disable_plaintext_auth =yes
log_path = /var/log/mail/err
info_log_path = /var/log/mail/info
ssl = yes   # 或者required
ssl_cert_file = /etc/ssl/dovecot/server.pem
ssl_key_file = /etc/ssl/dovecot/server.key
#mail_location = mbox:~/mail:INBOX=/var/mail/%u  ,这个指定邮件在什么位置,以便比那儿存取,


=========================================================================================================
了附 客户端的一些信息











推荐阅读
  • 这是原文链接:sendingformdata许多情况下,我们使用表单发送数据到服务器。服务器处理数据并返回响应给用户。这看起来很简单,但是 ... [详细]
  • 禁止程序接收鼠标事件的工具_VNC Viewer for Mac(远程桌面工具)免费版
    VNCViewerforMac是一款运行在Mac平台上的远程桌面工具,vncviewermac版可以帮助您使用Mac的键盘和鼠标来控制远程计算机,操作简 ... [详细]
  • REVERT权限切换的操作步骤和注意事项
    本文介绍了在SQL Server中进行REVERT权限切换的操作步骤和注意事项。首先登录到SQL Server,其中包括一个具有很小权限的普通用户和一个系统管理员角色中的成员。然后通过添加Windows登录到SQL Server,并将其添加到AdventureWorks数据库中的用户列表中。最后通过REVERT命令切换权限。在操作过程中需要注意的是,确保登录名和数据库名的正确性,并遵循安全措施,以防止权限泄露和数据损坏。 ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 使用在线工具jsonschema2pojo根据json生成java对象
    本文介绍了使用在线工具jsonschema2pojo根据json生成java对象的方法。通过该工具,用户只需将json字符串复制到输入框中,即可自动将其转换成java对象。该工具还能解析列表式的json数据,并将嵌套在内层的对象也解析出来。本文以请求github的api为例,展示了使用该工具的步骤和效果。 ... [详细]
  • 本文详细介绍了在ASP.NET中获取插入记录的ID的几种方法,包括使用SCOPE_IDENTITY()和IDENT_CURRENT()函数,以及通过ExecuteReader方法执行SQL语句获取ID的步骤。同时,还提供了使用这些方法的示例代码和注意事项。对于需要获取表中最后一个插入操作所产生的ID或马上使用刚插入的新记录ID的开发者来说,本文提供了一些有用的技巧和建议。 ... [详细]
  • 本文介绍了一些Java开发项目管理工具及其配置教程,包括团队协同工具worktil,版本管理工具GitLab,自动化构建工具Jenkins,项目管理工具Maven和Maven私服Nexus,以及Mybatis的安装和代码自动生成工具。提供了相关链接供读者参考。 ... [详细]
  • 本文介绍了在Linux下安装和配置Kafka的方法,包括安装JDK、下载和解压Kafka、配置Kafka的参数,以及配置Kafka的日志目录、服务器IP和日志存放路径等。同时还提供了单机配置部署的方法和zookeeper地址和端口的配置。通过实操成功的案例,帮助读者快速完成Kafka的安装和配置。 ... [详细]
  • SAP羞辱国产软件商:技术停在10年前
    SAP中国研究院总裁芮祥麟表示,国产软件厂商过于热衷概念炒作,技术水平停留在10年前的客户端架构水平。他认为,国内厂商推出基于SOA的产品或转型SAAS模式是不可能的,研发新架构需要时间。当前最热门的概念是云计算,芮祥麟呼吁国产厂商应该潜心研发底层架构。 ... [详细]
  • IT方面的论坛太多了,有综合,有专业,有行业,在各个论坛里混了几年,体会颇深,以前是论坛哪里人多 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • 本文讲述了孙悟空写给白骨精的信件引发的思考和反省。孙悟空在信中对自己的行为进行了反思,认识到自己胡闹的行为并没有给他带来实际的收获。他也揭示了西天取经的真相,认为这是玉皇、菩萨设下的一场陷阱。他还提到了师傅的虚伪和对自己的实心话,以及自己作为师傅准备提拔的对象而被派下来锻炼的经历。他认为路上的九九八十一难也都是菩萨算计好的,唐僧并没有真正的危险。最后,他提到了观音菩萨在关键时刻的指导。这封信件引发了孙悟空对自己行为的思考和反省,对西天取经的目的和自己的角色有了更深入的认识。 ... [详细]
  • 本文介绍了在Ubuntu下制作deb安装包及离线安装包的方法,通过备份/var/cache/apt/archives文件夹中的安装包,并建立包列表及依赖信息文件,添加本地源,更新源列表,可以在没有网络的情况下更新系统。同时提供了命令示例和资源下载链接。 ... [详细]
  • 本文详细介绍了使用 SQL Load 和 Excel 的 Concatenate 功能将数据导入 ORACLE 数据库的方法和步骤,同时介绍了使用 PL/SQL tools 将数据导入临时表的方法。此外,还提供了一个转链接,可参考更多相关内容。摘要共计XXX字。 ... [详细]
author-avatar
du-qhy
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有