前不久公司更新了邮件服务器,本来运行很正常的post-commit脚本就不能够发邮件了,而且每次commit后都会出现UTF-8相关的错误,错误如下:
"Error: Valid UTF-8 data" & relay check local fail" TITLE="SVN "Error: Valid UTF-8 data" & relay check local fail" />
在网上查了相关错误,都说是因为svn库里有文件的名字不是utf-8编码的。但是我建的测试库里根本全是英文名的文件,所以我的这个错误和编码无关。
在网上查了相关错误,都说是因为svn库里有文件的名字不是utf-8编码的。但是我建的测试库里根本全是英文名的文件,所以我的这个错误和编码无关。
之后我又发现不使用post-commit脚本的话,这个错误也不会出现。所以这个错误应该和post-commit中调用的commit-email.pl相关。
我又尝试直接使用commit-email.pl发送邮件,发现错误如下:
[root@localhost hooks]# /usr/bin/commit-email.pl /svnstore/utf8_email 3 --from admin@abc.com -s "utf8_email" --diff n
pm@abc.com
/usr/bin/commit-email.pl: SMTP Error:relay check local fail. (?????û?????ͨ????֤)
关于这个错误,网上查到的结果是:
553 relay check local fail.(本域用户必须通过验证)
所以第一步要解决发送
邮件失败的问题:
根据553的错误,如下修改
commit-email.pl脚本:
my ($sendmail, $smtp_server);
改为my($sendmail, $smtp_server,
$username,$passwd);
$smtp_server = " smtp.abc.com";
$username='mailaccount@abc.com';
$passwd='*******';
my $smtp = Net::SMTP->new($smtp_server)
or die "$0: error opening SMTP session to `$smtp_server':$!/n";
之后加入 handle_smtp_error($smtp,$smtp->auth("$username", "$passwd"));
$smtp_server = " smtp.abc.com";
$username='mailaccount@abc.com';
$passwd='*******';
my $smtp = Net::SMTP->new($smtp_server)
or die "$0: error opening SMTP session to `$smtp_server':$!/n";
之后加入 handle_smtp_error($smtp,$smtp->auth("$username", "$passwd"));
修改完毕后,再次直接运行commit-email.pl命令,发现错误变成:
[root@localhost hooks]#/usr/bin/commit-email.pl /svnstore/utf8_email 3 --fromadmin@abc.com -s "utf8_email" --diff n
pm@abc.com
SMTP Error: Need MIME::Base64 andAuthen::SASL todo auth
再次搜索万能的网络,得知解决方案是安装libauthen-sasl-perl包,安装方法如下:
# tar zxvf Authen-SASL-2.10.tar.gz
# cd Authen-SASL-2.10
# perl Makefile.pl
# make test //会有错误,忽略就好
# make install
# cd Authen-SASL-2.10
# perl Makefile.pl
# make test
# make install
安装成功后,发现一切问题都解决了,邮件可以正常发送,UTF8错误也没有了。这个错误还真是出现和消失的都莫名其妙啊