postfix.docx
- 文档编号:25250778
- 上传时间:2023-06-06
- 格式:DOCX
- 页数:20
- 大小:25.19KB
postfix.docx
《postfix.docx》由会员分享,可在线阅读,更多相关《postfix.docx(20页珍藏版)》请在冰豆网上搜索。
postfix
postfix的搭建
1postfix安装
修改你们的源
baseurl=http:
//192.168.1.222/postfix/
2yumcleanall
3yuminstallpostfix-y
MTA
切换MTA
#servicesendmailstop
#alternatives--configmta
#alternatives--configmta
#chkconfigsendmailoff
#chkconfigpostfixon
生成postfix的默认配置信息!
#postconf-n>/etc/postfix/main.cf
搭建DNS
zone"extmail.org"{
typemaster;
file"extmail.org.zone";
};
修改主机名#hostnamemail.extmail.org
保证dns指向正确
#cat/etc/resolv.confnameserver192.168.1.222
启动服务servicepostfixstart
进行一个简单的测试!
mail发信测试!
如果ok没问题可以继续,有问题看/var/log/maillog
设置简单的配置文件
config_directory=/etc/postfix
#hostname
mynetworks=127.0.0.1
myhostname=mail.extmail.org
mydomain=extmail.org
mydestination=$mynetworks$myhostname$mydomain
#banner
mail_name=linmeimeipostfix
smtpd_banner=$myhostnameESMTP$mail_name
#如果有错误立即响应
smtpd_error_sleep_time=0s
#邮件控制
message_size_limit=5242880
mailbox_size_limit=5242880
show_user_unknown_table_name=no
#这行是防止收信时看到的信,收件人是
#From:
root@mail.extmail.org
#To:
undisclosed-recipients:
;
#邮件发不出去在邮件队列中存活的时间
maximal_queue_lifetime=1d
#存在弹回队列的时间!
bounce_queue_lifetime=1d
发送一封测试邮件!
[root@node2data]#telnetlocalhost25
Trying127.0.0.1...
Connectedtolocalhost.localdomain(127.0.0.1).
Escapecharacteris'^]'.
220mail.extmail.orgESMTPlinmeimeipostfix
helolocalhost
250mail.extmail.org
mailfrom:
root@mail.extmail.org
2502.1.0Ok
rcptto:
hello@mail.extmail.org
2502.1.5Ok
data
354Enddatawith
subject:
hello
hello~~~~~~~
2502.0.0Ok:
queuedas501E92C53D9
如果远程收信还需要?
pop3,imap
#yuminstalldovecot-y
测试一下,ok没问题!
[root@node2/]#telnetlocalhost110
Trying127.0.0.1...
Connectedtolocalhost.localdomain(127.0.0.1).
Escapecharacteris'^]'.
+OKDovecotready.
userhello
+OK
pass123
+OKLoggedin.
list
+OK1messages:
1508
.
retr1
+OK508octets
关于postfix的认证!
sendmail有认证
postfix认证使用的是courier-authlib
#yuminstallcourier-authlibcourier-authlib-mysqlcourier-authlib-devel-y
配置/etc/authlib/authmysqlrc
vim/etc/authlib/authmysqlrc
MYSQL_SERVERlocalhost
MYSQL_USERNAMEextmail
MYSQL_PASSWORDextmail
#这个extmail用户,在后面生成
MYSQL_SOCKET/var/lib/mysql/mysql.sock
MYSQL_PORT3306
MYSQL_OPT0
MYSQL_DATABASEextmail
MYSQL_USER_TABLEmailbox
MYSQL_CRYPT_PWFIELDpassword
MYSQL_UID_FIELDuidnumber
MYSQL_GID_FIELDgidnumber
MYSQL_LOGIN_FIELDusername
MYSQL_HOME_FIELDhomedir
MYSQL_NAME_FIELDname
MYSQL_MAILDIR_FIELDmaildir
MYSQL_QUOTA_FIELDquota
MYSQL_SELECT_CLAUSEselectusername,password,"",uidnumber,gidnumber,concat('/home/domains/',homedir),concat('/home/domains/',maildir),quota,namefrommailboxwhereusername='$(local_part)@$(domain)'
#yuminstallmysql-server
#chkconfigmysqldon
这个服务器启动以后,就去问mysql就好了,别人别去问!
#vim/etc/authlib/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authmysql"
启动服务!
[root@node2/]#/etc/init.d/courier-authlibstart
如果这个目录的权限不正确,会造成无法正常获得用户信息!
[root@node2/]#chmod755/var/spool/authdaemon/
安装一个新的MDAmaildrop
yuminstallmaildrop
编辑postfix的配置文件(master.cf,使postfix知道自己有maildrop这个设备!
)
[root@node2/]#vim/etc/postfix/master.cf
添加2行
maildropunix-nn--pipe
flags=DRhuuser=vuserargv=maildrop-w90-d${user}@${nexthop}${recipient}${user}${extension}{nexthop}
#vim/etc/postfix/main.cf
给maildrop投递信件的时候,每次1封
maildrop_destination_recipient_limit=1
正确安装完以后,在/home/domains应该有这个目录,这个目录就是vuser(maildrop产生的)的家目录
重启postfix测试
[root@node2/]#maildrop-v|grepenable
GDBMextensionsenabled.
CourierAuthenticationLibraryextensionenabled.
Maildirquotaextensionenabled.
现在认证过信件会交给maildrop来处理!
先搞定apache
vimapache的主配置文件,httpd.conf
NameVirtualHost*:
80
Includeconf.d/vhost_*.conf
[root@node2conf.d]#cat/etc/httpd/conf.d/vhost_extmail.conf
80> ServerNamemail.extmail.org DocumentRoot/var/www/extsuite/extmail/html ScriptAlias/extmail/cgi//var/www/extsuite/extmail/cgi/ Alias/extmail/var/www/extsuite/extmail/html ScriptAlias/extman/cgi//var/www/extsuite/extman/cgi/ Alias/extman/var/www/extsuite/extman/html/ SuexecUserGroupvuservgroup
安装webmail
extmail前台邮箱
extman后台管理
#yuminstallextsuite-webmail-y
[root@node2extmail]#cp/var/www/extsuite/extmail/webmail.cf.defaultwebmail.cf
[root@node2extmail]#vimwebmail.cf
SYS_MYSQL_USER=extmail
SYS_MYSQL_PASS=extmail
SYS_MYSQL_DB=extmail
SYS_MYSQL_HOST=localhost
SYS_MYSQL_SOCKET=/var/lib/mysql/mysql.sock
[root@node2extmail]#chown-Rvuser.vgroup/var/www/extsuite/extmail/cgi/
#yuminstallextsuite-webman-y
[root@node2extmail]#chown-Rvuser.vgroup/var/www/extsuite/extman/cgi/
[root@node2extmail]#mkdir/tmp/extman
[root@node2extmail]#chown-Rvuser.vgroup/tmp/extman/
导入数据库!
[root@node2extmail]#mysql-uroot-p
[root@node2extmail]#mysql-uroot-p
可以去mysql中查看一下!
设置虚拟域,还有虚拟用户(信息都存放在mysql数据库中)1
[root@node2docs]#cp/var/www/extsuite/extman/docs/mysql_virtual_alias_maps.cfmysql_virtual_domains_maps.cfmysql_virtual_mailbox_maps.cfmysql_virtual_sender_maps.cf/etc/postfix/
配置postfix
vimmain.cf
virtual_alias_maps=mysql:
/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains=mysql:
/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps=mysql:
/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport=maildrop:
另外修改mydestination,去掉$mydomain,不然会报警
mydestination=$mynetworks$myhostname
测试authlib
[root@node2docs]#/usr/sbin/authtest-sloginpostmaster@extmail.orgextmail
Authenticated:
postmaster@extmail.org(uid1000,gid1000)
HomeDirectory:
/home/domains/extmail.org/postmaster
Maildir:
/home/domains/extmail.org/postmaster/Maildir/
Quota:
104857600S
EncryptedPassword:
$1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
CleartextPassword:
extmail
Options:
(none)
Authenticationsucceeded.
注意:
HomeDirectory:
/home/domains/extmail.org/postmaster
你cd/home/domains里面去看看,如果有这个目录就对了!
如果没有去查看authlibmysqlrc中的select字段!
后台的密码为extmail*123*
启动图形日志
启动mailgraph_ext
[root@node2cur]#/usr/local/mailgraph_ext/mailgraph-initstart
Startingmailstatisticsgrapher:
mailgraph_ext
Startingqueuestatisticsgrapher:
qmonitor
启动cmdserver(后台显示系统信息)
[root@node2cur]#/var/www/extsuite/extman/daemon/cmdserver--daemon
loadedok
如果需要可以设置为开机启动!
删除默认的pop3
[root@mailcur]#/etc/init.d/dovecotstop
[root@mailcur]#rpm-edovecot
安装courier-authlibcourier-imap
[root@mailHPv115w]#rpm-ivh/var/www/html/doc/courier-imap-4.3.1.20080621-7.1.i386.rpm
配置courier-imap
#vim/usr/lib/courier-imap/etc/imapd-ssl
IMAPDSSLSTART=NO
#/etc/init.d/courier-imaprestart
courier-imap通过courier-authlib获得的用户信息(mysql)
关于中继认证
默认系统中的cyrus-sasl不支持authdaemon
[root@node2all]#rpm-ecyrus-sasl--nodeps
[root@node2all]#rpm-ecyrus-sasl-devel--nodeps
如果之前安装过,最好重启一下,以免一会冲突,死活不好用!
#yuminstallcyrus-sasl
#vimmain.cf
#针对收件人的限制
smtpd_recipient_restrictions=
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname
#针对发信人的限制
smtpd_sender_restrictions=
permit_mynetworks,
reject_sender_login_mismatch,
reject_authenticated_sender_login_mismatch,
reject_unauthenticated_sender_login_mismatch
smtpd_sender_login_maps=
mysql:
/etc/postfix/mysql_virtual_sender_maps.cf,
mysql:
/etc/postfix/mysql_virtual_alias_maps.cf
#开启认证
broken_sasl_auth_clients=yes
smtpd_sasl_auth_enable=yes
smtpd_sasl_local_domain=$myhostname
smtpd_sasl_security_options=noanonymous
编辑smtpd.conf文件
vim/usr/lib/sasl2/smtpd.conf
pwcheck_method:
authdaemond
log_level:
3
mech_list:
PLAINLOGIN
authdaemond_path:
/var/spool/authdaemon/socket
重启postfix
/etc/init.d/postfixrestart
测试:
[root@node2mail]#perl-e'useMIME:
:
Base64;printencode_base64("postmaster\@extmail.org")';
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@node2all]#perl-e'useMIME:
:
Base64;printencode_base64("extmail")';
ZXh0bWFpbA==
[root@node2mail]#telnetlocalhost25
Trying127.0.0.1...
Connectedtolocalhost.localdomain(127.0.0.1).
Escapecharacteris'^]'.
220mail.extmail.orgESMTPlinmeimeipostfix
authlogin
334VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334UGFzc3dvcmQ6
ZXh0bWFpbA==
2352.7.0Authenticationsuccessful
安装杀毒与过滤
1、yuminstallamavisd-new
yuminstallspamassassin-y
#rpm-ivhperl-IO-Multiplex-1.08-5.el5.noarch.rpm
#rpm-ivhperl-Net-Server-0.96-2.el5.noarch.rpm
#yuminstallamavisd-new设置相关目录权限:
#chown-Ramavis.amavis/var/spool/vscan/
2、配置SpamAssassin
Amavisd-new通过Mail:
:
SpamAssassin模块来调用SA的功能,因此这里配置SA和常规配置SA软件有些区别,主要集中在修改local.cf文件上。
/etc/mail/spamassassin/local.cf
增加中文规则:
用于处理中文(简体)垃圾邮件。
#wget-N-P/usr/share/spamassassin设置规则自动更新:
#/usr/bin/crontab-e然后输入如下的内容:
001**wget-N-P/usr/share/spamassassin/etc/init.d/amavisdrestart存盘退出即可。
最后运行以下调试命令以确认amavisd没有错误:
#/usr/sbin/amavisd-c/etc/amavisd/amavisd.confdebug
如果没有异常提示或报错退出则表示一切都正常,按ctrl+c终止,然后正常启动,若提示pid不存在等错误,不必理会。
设置amavisd开机自启:
#serviceamavisdstart
#chkconfigamavisdon
3、配置ClamAV
3、安装ClamAV杀毒的软件
#yuminstallclamd
编辑clamd.conf文件
#vi/etc/clamd.conf
去掉‘LocalSocket/var/run/clamav/clamd.sock’的注释,
并注释掉‘TCPSocket3310’,我们将使用unixsocket而不是TCP,两者不可并存。
变动内容见下:
#Default:
disabled
LocalSocket/var/run/clamav/clamd.sock
#TCPSocket3310
设置相关目录权限:
将clamav加到amavis运行组里,并调整目录权限,否则clamav将无法扫描amavisd-new产生的临时文件
#gpasswd-aclamavamavis
#usermod-Gamavisclamav
#chownamavis.amavis/var/spool/vscan
#chmod750/var/spool/vscan
#chownamavis.amavis/var/spool/vscan/tmp
#chmod750/var/spool/vscan/tmp
默认的/var/spool/vscan目录属性是:
drwxr-x---5amavisamavis
对于clamav用户而言,则无任
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- postfix
![提示](https://static.bdocx.com/images/bang_tan.gif)