设为首页 收藏本站
查看: 1443|回复: 0

[经验分享] sendmail 安装

[复制链接]

尚未签到

发表于 2015-11-25 10:07:44 | 显示全部楼层 |阅读模式
  linux gateway
ifconfig eth0 192.168.5.50 netmask 255.255.255.0
route add default gw 192.168.5.11
  
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
  PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
  Alternatively you can run:
/usr/bin/mysql_secure_installation
  which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
  See the manual for more instructions.
  You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
  You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
  Please report any problems with the /usr/bin/mysqlbug script!
  The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [  OK  ]
Starting MySQL:                                            [  OK  ]
You have mail in /var/spool/mail/root
  LUSH PRIVILEGES;
  INSERT INTO mysql.user ( HOST, USER, PASSWORD, select_priv, insert_priv,               update_priv,
  delete_priv,  create_priv, drop_priv, reload_priv, shutdown_priv,               process_priv,  file_priv,
  grant_priv, references_priv, index_priv, alter_priv, show_db_priv, super_priv, create_tmp_table_priv,
  lock_tables_priv,                   execute_priv, repl_slave_priv, repl_client_priv, create_view_priv,
  show_view_priv, create_routine_priv, alter_routine_priv, create_user_priv ) VALUES ( '%', 'b',
  PASSWORD('b'), 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y',
  'Y', 'Y', 'Y', 'Y', 'Y' );
/*[23:06:31][   0 ms]*/ FLUSH PRIVILEGES;
  
  /////////////////////////////
1.使用mysqladmin修改mysql密码
C:\>mysqladmin -udbuser -p password newpass
Enter password: oldpass
当然用此命令的前提是你把mysql加入了环境变量,如果没有加入环境变量的话那只能在命令行下cd到
  mysqladmin所在的目录下与此那个次命令了!
-----------------------------------------
2.重置root密码
方法一:
在my.ini的[mysqld]字段加入:
skip-grant-tables
重启mysql服务,这时的mysql不需要密码即可登录数据库
然后进入mysql
mysql>use mysql;
mysql>update user set password=password('新密码') WHERE User='root';
mysql>flush privileges;
运行之后最后去掉my.ini中的skip-grant-tables,重启mysqld即可。
修改mysql密码方法二:
不使用修改my.ini重启服务的方法,通过非服务方式加skip-grant-tables运行mysql来修改mysql密码
停止mysql服务
打开命令行窗口,在bin目录下使用mysqld-nt.exe启动,即在命令行窗口执行: mysqld-nt --skip-grant-
  tables
然后另外打开一个命令行窗口,登录mysql,此时无需输入mysql密码即可进入。
按以上方法修改好密码后,关闭命令行运行mysql的那个窗口,此时即关闭了mysql,如果发现mysql仍在运行
  的话可以结束掉对应进程来关闭。
启动mysql服务
  -----------------------------------------
  记住此方法,走遍天下无mysql密码
  ///////////////////////////////
  mysql> Update user SET password=PASSWORD("new password") Where user=’name’;
  
mysql> FLUSH PRIVILEGES;
  
mysql> QUIT
  使用--skip-grant-tables参数启动MySQL Server
  
shell>mysqld_safe --skip-grant-tables &
  
4.为root@localhost设置新密码
  
shell>mysqladmin -u root flush-privileges password "newpassword"
  
//////////////////////////////////
安装dovecot-1.0.7-7.el5.i386服务的时候出现
  libpq.so.4 is needed by dovecot-1.0.7-7.el5.i386
  解决方法:
http://hi.baidu.com/why8498/blog/item/756106376f4543d7a2cc2b3a.html
在使用m4处理sendmail.mc的时候,为什么会出现错误"m4: Cannot open /usr/share/sendmail-
  cf/m4/cf.m4: No such file or directory"?
  
这个错误表示sendmail-cf这个软件包没有安装,可以使用up2date或者从Red Hat Network(RHN)中下载安
  装sendmail-cf软件包;如果系统已经注册到RHN上可以使用up2date安装软件包,以root用户执行下面命令
  :
  
  error: Failed dependencies:
        libmysqlclient.so.15 is needed by dovecot-1.0.7-7.el5.i386
        libmysqlclient.so.15(libmysqlclient_15) is needed by dovecot-1.0.7-7.el5.i386
        libpq.so.4 is needed by dovecot-1.0.7-7.el5.i386
  安装以下rpm包就OK了!
rpm -ivh perl-DBI-1.52-2.el5.i386.rpm
rpm -ivh mysql-5.0.45-7.el5.i386.rpm
rpm -ivh postgresql-libs-8.1.11-1.el5_1.1.i386.rpm
rpm -ivh dovecot-1.0.7-7.el5.i386.rpm

、、、、、、、、、、、、、、、、、、、、、、、、、、
  
  查看安装
rpm -qa | grep sendmail
rpm -qa | grep dovecot
rpm -qa | grep cyrus
安装邮件服务器
yum install sendmail sendmail-cf
安装pop3/imap服务
yum install dovecot
  安装用户认证
yum install cyrus-sasl
yum install cyrus-sasl-md5
yum install cyrus-sasl-plain
yum install cyrus-sasl-lib
  修改sendmail配置
vi /etc/mail/sendmail.mc
  第42行和43行,把最前面的dnl删除,变成:
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS',`EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
  修改SMTP的监听IP为 0.0.0.0
DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
  生成配置
m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
***************************
如果出现:sendmail.mc:10: m4: cannot open `/usr/share/sendmail-cf/m4/cf.m4': No such file or
  directory
说明需要安装sendmail-cf
yum install sendmail-cf
***************************
  
修改dovecot配置
vi /etc/dovecot.conf
去掉下面一行前面的#
#protocols =imap imaps pop3 pop3s
  
添加域名
vi /etc/mail/local-host-names
添加域名如:dirtysea.com //每个域名一行
  修改认证方式
vi /usr/lib/sasl2/Sendmail.conf 里面指明了:pwcheck_method=saslauthd,不做修改
vi /etc/sysconfig/saslauthd 找到第7行的:MECH= 改成:MECH=shadow
保存
如下示列:
  [iyunv@mail]# cat /usr/lib/sasl2/Sendmail.conf
pwcheck_method:saslauthd
[iyunv@mail]# cat /usr/lib/sasl2/smtpd.conf.rpmsave
log_level: 3
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
[iyunv@mail]# cat /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so
# on. This directory must already exist.
SOCKETDIR=/var/run/saslauthd
# Mechanism to use when checking passwords. Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Additional flags to pass to saslauthd on the command line. See saslauthd(8)
# for the list of accepted flags.
FLAGS=
[iyunv@mail]#testsaslauthd -u test -p 123456 (验证smtp)
0: OK "Success."
  
  
  
添加邮件用户
[iyunv@localhost named]# groupadd mailuser
[iyunv@localhost named]# adduser -g mailuser -s /sbin/nologin test
这样添加的用户名就没有了shell,只能收发信而不能登录到服务器运行其他程序
  
设置开机启动
chkconfig sendmail on
chkconfig dovecot on
chkconfig saslauthd on
  重启
service sendmail restart
service dovecot restart
service saslauthd restart
  验证Sendmail服务
telnet localhost 25 //输入helo localhost 此时应该有LOGIN PLAIN的字样,即表示SMTP认证设置成功。
  [iyunv@centos5 mail]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 centos5 ESMTP Sendmail 8.13.8/8.13.8; Thu, 6 May 2010 06:21:29 +0800
helo localhost
250 centos5 Hello localhost.localdomain [127.0.0.1], pleased to meet you
mail from:
250 2.1.0 ... Sender ok
rcpt to: (要测试向外发送邮件就填写网络上存在的邮件地址)
250 2.1.5 ... Recipient ok
data
354 Enter mail, end with "." on a line by itself
From: alin
To: alin
Subject: Hello
test
.
250 2.0.0 o45MLTcH005157 Message accepted for delivery
quit
221 2.0.0 centos5 closing connection
Connection closed by foreign host.
  
  
ok,可以使用outlook或foxmail进行测试收发了。
  注意:为什么没有设定foxmail中的smtp服务器需要验证,也可以发送E-mail?
要用OUTLOOK来测试,Foxmail似乎可以自动地进行smtp认证。OUTLOOK在smtp服务器验证失败后,有
  拒绝提示
  工具->;帐户->;邮件->;属性->;服务器->;我的服务器要求身份验证(选上)->;设置->;(选择)登录方式->;帐户
  名:(用saslpasswd2建立的),密码(用saslpasswd2建立的)->;确定.
另外:接收邮件服务器的帐户名与密码应该是系统里的用户名与密码.
  
saslauthd -v 看结果支不支持 pam或shadow
smtp验证测试: testsaslauthd -u test -p 123456
sasldblistusers2 检查已经增加的smtp验证用户
saslpasswd2增加smtp验证用户:saslpasswd2 -u cencn.com -c test
  
查看sendmail队列:mailq
立即发送队列里的邮件: sendmail –oQ/var/spool/mqueue.stop -q
察看邮件系统的状态:mailstats
查看暂时存储邮件:ls -l /var/spool/mail |more
  
  、、、、、、、、、、、、、、、、、、
问题
testsaslauthd connect() : No such file or directory
解决
加上:-f /var/state/saslauthd/mux,用下边的命令即可
testsaslauthd -s smtpd -u root -p 1111111 -f /var/state/saslauthd/mux
、、、、、、、、、、、、、、、、、、、
  问题
connect() : Connection refused(连接被拒绝)
解决
  ······························································
  makemap hash access < access        
  
RoundCube Webmail登录不了!!急
http://www.extmail.org/forum/viewthread.php?tid=8425
进入登录界面后,总是login failed.查看dovecot.log如下:
dovecot: Jul 25 09:48:17 Error: auth-worker(default): sql(vmail,127.0.0.1): Password query failed: Not
  connected to database
dovecot: Jul 25 09:48:19 Info: imap-login: Disconnected (auth failed, 1 attempts): user=<vmail>,
  method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, secured
查看邮件日志如下:
IMAP Error: Authentication for admin@oa.geniusinform.com failed (LOGIN): &quot;a001 NO Temporary
  authentication failure.&quot; in  on line 0
大虾们帮帮我,谢谢谢谢谢....急!!!
我也碰到这个问题.
找了两天才发现问题出在dovecot.conf,修改以下字段就行了
auth_username_format = %n

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-143302-1-1.html 上篇帖子: 查看sendmail日志 下篇帖子: sendmail安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表