Press "Enter" to skip to content

Month: 2011年3月

【原创】CentOS5.5下postfix邮件系统安装配置

热度 3,959 度

CentOS5.5下PostFix邮件系统配置,采用比较简单的yum来进行安装,当然也可以用源码进行编译安装。

邮件postfix发送安装配置

[root@dyq ~]# yum -y install postfix #输入安装postfix
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.ustc.edu.cn
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
addons                                                              |  951 B     00:00
base                                                                | 2.1 kB     00:00
extras                                                              | 2.1 kB     00:00
updates                                                             |  951 B     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package postfix.i386 2:2.3.3-2.1.el5_2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

====================================================
Package             Arch             Version                       Repository        Size
====================================================
Installing:
postfix             i386             2:2.3.3-2.1.el5_2             base             3.6 M

Transaction Summary
====================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 3.6 M
Downloading Packages:
postfix-2.3.3-2.1.el5_2.i386.rpm                                    | 3.6 MB     00:27
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : postfix                                                             1/1

Installed:
postfix.i386 2:2.3.3-2.1.el5_2

Complete!
[root@dyq ~]# vim /etc/postfix/main.cf

myhostname = mail.kiccleaf.com
mydomain = kiccleaf.com
myorigin=$mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
relay_domains = $mydestination
mynetworks = 192.168.1.0/28, 127.0.0.0/8,60.191.49.228/24 #填写自己的公网ip
home_mailbox = Maildir/
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  ← 找到这一行,接此行添加如下行:
smtpd_banner = $myhostname ESMTP unknow ← 添加这一行,不显示SMTP服务器的相关信息

在配置文件的文尾,添加如下行:

smtpd_sasl_auth_enable = yes  ← 服务器使用SMTP认证
smtpd_sasl_local_domain = $myhostname  ← 指定SMTP认证的本地域名(主机名)
smtpd_sasl_security_options = noanonymous   ← 不允许匿名的方式认证
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 15728640

[root@dyq ~]# vi /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd  ← 找到此行,将“saslauthd”改为“auxprop”
↓
pwcheck_method: auxprop  ← 不使用系统用户密码作为用户的SMTP认证密码

[root@dyq ~]# vi /etc/sysconfig/saslauthd
MECH=shadow  ← 找到这一行,在前面加#
↓
#MECH=shadow  ← 不使用shadow机制

FLAGS=  ← 找到此行,在等号后面添加“sasldb”
↓
FLAGS=sasldb   ← 定义认证方式为sasldb2

[root@dyq ~]# mkdir /etc/skel/Maildir
[root@dyq ~]# chmod 700 /etc/skel/Maildir
[root@dyq ~]# ll /home/
total 8
drwx------ 2 mysql mysql 4096 Mar 18 00:51 mysql
drwx------ 2 www   www   4096 Mar 18 01:52 www
[root@dyq ~]# adduser leaf #添加一个用户leaf
[root@dyq ~]# ll /home/ #查看用户是否创建
total 12
drwx------ 3 leaf  leaf  4096 Mar 21 11:02 leaf
drwx------ 2 mysql mysql 4096 Mar 18 00:51 mysql
drwx------ 2 www   www   4096 Mar 18 01:52 www
[root@dyq ~]# passwd leaf #配置leaf用户的密码
Changing password for user leaf.
New UNIX password:                         #输入leaf用户密码
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:       #再次输入leaf用户密码
passwd: all authentication tokens updated successfully.

[root@dyq ~]# mkdir /home/leaf/Maildir (默认情况下已经创建)
mkdir: cannot create directory `/home/leaf/Maildir': File exists

[root@dyq ~]# chmod 700 /home/leaf/Maildir
[root@dyq ~]# chown leaf. /home/leaf/Maildir
[root@dyq ~]# saslpasswd2 -u mail.kiccleaf.com -c leaf
Password: #输入leaf用户密码
Again (for verification):#再次输入leaf用户密码

[root@dyq ~]# chgrp postfix /etc/sasldb2
[root@dyq ~]# chmod 640 /etc/sasldb2
[root@dyq ~]# alternatives --config mta

There are 2 programs which provide 'mta'.

Selection    Command
-----------------------------------------------
*+ 1           /usr/sbin/sendmail.sendmail
2           /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number: 2 #选择2

[root@dyq ~]# chkconfig saslauthd on #添加到服务,以后可以直接用service saslauthd [start/stop/restart]进行操作
[root@dyq ~]# chkconfig --list saslauthd #查看是否为系统自动启动 2~5 为on
saslauthd          0:off    1:off    2:on    3:on    4:on    5:on    6:off
[root@dyq ~]# /etc/rc.d/init.d/saslauthd start #启动服务
Starting saslauthd:                                        [  OK  ]
[root@dyq ~]# chkconfig postfix on #添加到服务,以后可以直接用service postfix [start/stop/restart]进行操作
[root@dyq ~]# chkconfig --list postfix #查看是否为系统自动启动 2~5 为on
postfix            0:off    1:off    2:on    3:on    4:on    5:on    6:off
[root@dyq ~]# /etc/rc.d/init.d/postfix start #启动服务
Starting postfix:                                          [  OK  ]

POP / IMAP 服务器的构建( Dovecot )

[root@dyq ~]# yum -y install dovecot
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.ustc.edu.cn
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
addons                                                              |  951 B     00:00
base                                                                | 2.1 kB     00:00
extras                                                              | 2.1 kB     00:00
updates                                                             |  951 B     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dovecot.i386 0:1.0.7-7.el5 set to be updated
--> Processing Dependency: libmysqlclient.so.15 for package: dovecot
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15) for package: dovecot
--> Processing Dependency: libpq.so.4 for package: dovecot
--> Running transaction check
---> Package mysql.i386 0:5.0.77-4.el5_5.4 set to be updated
--> Processing Dependency: perl(DBI) for package: mysql
---> Package postgresql-libs.i386 0:8.1.22-1.el5_5.1 set to be updated
--> Running transaction check
---> Package perl-DBI.i386 0:1.52-2.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

===================================================
Package                  Arch          Version                     Repository        Size
===================================================
Installing:
dovecot                  i386          1.0.7-7.el5                 base             1.6 M
Installing for dependencies:
mysql                    i386          5.0.77-4.el5_5.4            updates          4.8 M
perl-DBI                 i386          1.52-2.el5                  base             600 k
postgresql-libs          i386          8.1.22-1.el5_5.1            updates          196 k

Transaction Summary
==================================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 7.2 M
Downloading Packages:
(1/4): postgresql-libs-8.1.22-1.el5_5.1.i386.rpm                    | 196 kB     00:01
(2/4): perl-DBI-1.52-2.el5.i386.rpm                                 | 600 kB     00:03
(3/4): dovecot-1.0.7-7.el5.i386.rpm                                 | 1.6 MB     00:09
(4/4): mysql-5.0.77-4.el5_5.4.i386.rpm                              | 4.8 MB     00:34
-------------------------------------------------------------------------------------------
Total                                                      151 kB/s | 7.2 MB     00:48
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : perl-DBI                                                            1/4
Installing     : mysql                                                               2/4
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
Installing     : postgresql-libs                                                     3/4
Installing     : dovecot                                                             4/4

Installed:
dovecot.i386 0:1.0.7-7.el5

Dependency Installed:
mysql.i386 0:5.0.77-4.el5_5.4                      perl-DBI.i386 0:1.52-2.el5
postgresql-libs.i386 0:8.1.22-1.el5_5.1

Complete!

[root@dyq ~]# vi /etc/dovecot.conf
protocols = imap pop3
default_mail_env = maildir:~/Maildir

#如果开启防火墙Iptables 请添加以下端口

[root@dyq ~]# iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp--dport 25 -j ACCEPT
[root@dyq ~]# iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
[root@dyq ~]# iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT
[root@dyq ~]# /etc/rc.d/init.d/iptables save #保存刚添加的记录
Saving firewall rules to /etc/sysconfig/iptables:          [  OK  ]
[root@dyq ~]# /etc/init.d/iptables restart #重启防火墙
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_n[  OK  ]
[root@dyq ~]# chkconfig dovecot on #添加到服务,以后可以直接用service dovecot [start/stop/restart]进行操作
[root@dyq ~]# chkconfig --list dovecot #查看是否为系统自动启动 2~5 为on
dovecot            0:off    1:off    2:on    3:on    4:on    5:on    6:off
[root@dyq ~]# /etc/rc.d/init.d/dovecot start #启动服务
Starting Dovecot Imap:                                     [  OK  ]

测试php邮件发送

[root@dyq www]# vim mail.php

<?php
$to      = 'kiccleaf@163.com';
$subject = 'the subject test';
$message = 'hello!测试用例!';
$headers = 'From: leaf@kiccleaf.com' . "\r\n" .
'Reply-To:  leaf@kiccleaf.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

打开浏览器http://youip/mail.php   再查看邮件是否已经收到邮件

也可以用foxmail客户端进行测试。

Leave a Comment

centos5 更新kernel的方法

热度 2,721 度

Linux 下更新kernel的方法以下是配置:

[root@kiccleaf ~]# file /sbin/init #查看当前系统是32位或64位系统
/sbin/init: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@kiccleaf ~]# yum list kernel* #列出可更新的内容
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.163.com
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
addons                                                              |  951 B     00:00
base                                                                | 2.1 kB     00:00
extras                                                              | 2.1 kB     00:00
updates                                                             | 1.9 kB     00:00
Not using downloaded repomd.xml because it is older than what we have:
Current   : Sun Mar 13 01:44:04 2011
Downloaded: Fri Jan  7 17:26:51 2011
Installed Packages
kernel.i686                                2.6.18-194.el5                         installed
kernel.i686                                2.6.18-194.32.1.el5                    installed
kernel-headers.i386                        2.6.18-194.32.1.el5                    installed
Available Packages
kernel-PAE.i686                            2.6.18-194.32.1.el5                    updates
kernel-PAE-devel.i686                      2.6.18-194.32.1.el5                    updates
kernel-debug.i686                          2.6.18-194.32.1.el5                    updates
kernel-debug-devel.i686                    2.6.18-194.32.1.el5                    updates
kernel-devel.i686                          2.6.18-194.32.1.el5                    updates
kernel-doc.noarch                          2.6.18-194.32.1.el5                    updates
kernel-xen.i686                            2.6.18-194.32.1.el5                    updates
kernel-xen-devel.i686                      2.6.18-194.32.1.el5                    updates
[root@kiccleaf ~]# yum install kernel-PAE.i686 -y #PAE为支持大内存的版本
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.ustc.edu.cn
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Setting up Install Process
Resolving Dependencies
--&gt; Running transaction check
---&gt; Package kernel-PAE.i686 0:2.6.18-194.32.1.el5 set to be installed
--&gt; Finished Dependency Resolution

Dependencies Resolved

====================================================
Package              Arch           Version                       Repository         Size
====================================================
Installing:
kernel-PAE           i686           2.6.18-194.32.1.el5           updates            17 M

Transaction Summary
====================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 17 M
Downloading Packages:
kernel-PAE-2.6.18-194.32.1.el5.i686.rpm                             |  17 MB     01:59
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : kernel-PAE                                                          1/1

Installed:
kernel-PAE.i686 0:2.6.18-194.32.1.el5

Complete!
[root@kiccleaf ~]#reboot   #重启系统

[root@kiccleaf ~]# uname -a #查看更后的版本
Linux kiccleaf 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:53:09 EST 2011 i686 i686 i386 GNU/Linux

Leave a Comment

关于本人

热度 4,215 度

关于本人

来无风,去无踪!平平淡淡的一个人!

专业从事技术研发,系统架构,高性能解决方案。欢迎广朋友相互交流。

QQ:53045936     注:叶子blog

3 Comments