Saslauthd服务实现SMTP发信认证

一、SMTP发信认证


通过sasl库中的saslauthd服务实现SMTP认证

二、部署


1.先安装postifx

2.生成sasl配置文件,实现使用sasl认证

vim /usr/lib64/sasl2/smtpd.conf    //编写sasl配置文件
  pwcheck_method:saslauthd
vim /etc/sysconfig/saslauthd    //将sasl验证方式改为系统用户密码验证
将MECH=pam改为MECH=shadow
/etc/init.d/saslauthd restart    //启动sasl认证服务
chkconfig --level 35 saslauthd on    //设置35级别的开机自启
chkconfig --list saslauthd      //验证saslauthd服务35级别是否启动
testsaslauthd -u hehe -p 123        //验证sasl工作是否正常

3.编辑postfix配置文件

vim /etc/postfix/main.cf

  queue_run_delay = 3s          //每3s扫描一次delay的邮件 
  minimal_backoff_time = 3s         //在3s内不会重发delay的邮件
  maximal_backoff_time = 6s         //在6s内则一定会重发邮件
  maximal_queue_lifetime = 12s      //邮件超过12s没有发出,则退信
  smtpd_sasl_auth_enable = yes      //启动SMTP认证
  smtpd_sasl_security_options = noanonymous //禁止匿名使用SMTP服务
  mynetworks = 127.0.0.1        //允许本服务器发送到外网地址
  smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination  //定义地址过滤规则

4.验证

/etc/init.d/postfix restart    //重启邮件服务
客户端telnet测试
telnet mail.xueluo.org 25
  EHLO mail.xueluo.org          //宣告地址
  AUTH LOGIN                //需进行认证登陆
  askw^&                    //输入加密的用户字符串(printf hehe | openssl base64)
  783jhs2                   //输入加密的用户密码(printf 123 | openssl base64)
  MAIL FROM:[email protected]
  RCPT TO:[email protected]
  DATA
  aaaaaaa
  .

三、Web界面发收邮件


web端软件可自行选择,这里使用squirrelmail,下载http://www.squirrelmail.org/

1.解压squirrelmail

tar -zxvf squirrelmail-webmail-1.4.22.tar.gz -C /usr/src/    //解压squirrelmail
yum -y install httpd php     //使用yum安装httpd和php软件包
cp -r /usr/src/squirrelmail-webmail-1.4.22/* /var/www/html/    //拷贝目录下的文件到Apache的网页目录
chown -R apache:apache /var/www/html/    //设置网页目录属主和属组为apache

2.配置

mv /var/www/html/config/config_default.php /var/www/html/config/config.php    //重命名模板文件为config.php
vim /var/www/html/config/config.php
118 $domain = 'xueluo.org';             //当前域
146 $smtpServerAddress = '192.168.1.10';        //SMTP服务IP
202 $imapServerAddress = '192.168.1.10';        //IMAP服务IP
212 $popServerAddress = '192.168.1.10';     //新增,POP服务IP
213 $popPort = 110;             //新增,POP服务端口    
259 $smtp_auth_mech = 'login';          //SMTP认证方式
mkdir -p /var/local/squirrelmail/data/    //新建目录
chown apache:apache /var/local/squirrelmail/data/    //设置apache为属主和属组
/etc/init.d/httpd start && chkconfig --level 35 httpd on    //重启服务,并设置35级别的开机自启

3.访问

浏览器 --> 192.168.1.10 -->输入用户名密码登录-->使用

四、设置postfix邮件附件大小


1. 修改/etc/php.ini

max_execution_time = 30    //改为60 (增加处理脚本的时间限制) 
memory_limit = 8M    //改为50M (这样才能发10M的附件) 
post_max_size = 2M    //改为50M 
upload_max_filesize = 2M    //改为50M

2. 修改/etc/postfix/main.cf

message_size_limit = 20480000

postfix的默认值是10M, 但这指的是邮件正文和编码后附件的总和, 经过base64编码,附件的大小会增加35%左右, 因此这里设定可接受邮件的大小为20M
可以使用如下命令查看postfix的有关设定:
#/usr/sbin/postconf | grep size

3. 修改/var/www/extsuite/extmail/webmail.cf

SYS_MESSAGE_SIZE_LIMIT = 51200000

猜你喜欢

转载自blog.51cto.com/13770206/2141049