借用smtp.qq.com发邮件
至于sentmail和postfix的配置有多么麻烦学生在这里就不多废话了…反正是配置了N个小时,最终弄的头晕眼花也没弄好…
下面的方法可以让你完全摆脱这两个工具…当然,你要是想做邮件服务器的话就令当别论了…你要是只想让服务器自动发个邮件什么的,用下面的就行了
通常的做法都是,关闭本机的sendmail服务或者postfix服务,
#执行下面的命令,各位大侠都对号入座吧
#sendmial
service sendmail stop
chkconfig sendmail off
#postfix
service postfix stop
chkconfig postfix off
#再狠一点就直接卸载吧..
yum remove sendmail yum remove postfix
# vi /etc/mail.rc set from=123456@qq.com set smtp=smtp.qq.com set smtp-auth-user=123456 set smtp-auth-password=sbsbsbsb set smtp-auth=login
然后通过命令来发送邮件,echo hello word | mail -s ” title” 123456@qq.com
# rpm -qa|grep mailx mailx-12.4-6.el6.x86_64 # ll /bin/mail* lrwxrwxrwx. 1 root root 5 7月 22 2011 /bin/mail -> mailx -rwxr-xr-x. 1 root root 390424 2月 16 2010 /bin/mailx # mail -V 12.4 7/29/08
RHEL5下,则发现了一些不同,mailx 链接到 mail 命令,mailx版本为8.1
# rpm -qa|grep mailx mailx-8.1.1-44.2.2 # ll /bin/mail* -rwxr-xr-x 1 root mail 84856 Jun 6 2007 /bin/mail lrwxrwxrwx 1 root root 4 Apr 12 18:03 /bin/mailx -> mail # mail -V 此处运行就会出错,没有-V这个参数
也就是说,在RHEL6\5下,运行mail 和mailx,实际上都是一个命令,而mail版本不同,导致了RHEL5下mail命令无法调用外部SMTP服务器。
下载后,# tar jxvf mailx-12.4.tar.bz2 9# cd mailx-12.4# make# make install UCBINSTALL=/usr/bin/install
查看mailx程序默认安装位置、及版本
# vi /etc/nail.rc (看出亮点了吗?) set from=123456@qq.com set smtp=smtp.qq.com set smtp-auth-user=123456 5 set smtp-auth-password=sbsbsbsb set smtp-auth=login
然后通过命令来发送邮件
check(){ srvid=$1 srvname=$2 grpname=$3 root=`cat server_$srvid.txt | awk \'{print $9}\' | awk -F% \'{print $1}\' ` data=`cat server_$srvid.txt | awk \'{print $10}\' | awk -F% \'{print $1}\' ` mysql -uroot -p1234 -e "load data infile \'$path/server_$srvid.txt\' into table serverdb.server_status;" &>/dev/null if [ $root -gt $deadline -o $data -gt $deadline ] then echo >>mail.log # cat server_$srvid.txt >>mail.log # cat server_$srvid.txt >>mail.txt echo -e "$grpname" >./srv_head.txt echo -e "$srvname" >>./srv_head.txt cat srv_head.txt server_$srvid.txt >>mail.log cat server_$srvid.txt |/bin/mail -s "DISKWARMING_$ts_$grpname_$srvname" forilen@dawx.com # cat server_$srvid.txt >>./srv_head.txt # echo "1" >>./srv_head.txt # cat srv_head.txt | /bin/mail -s "DISKWARMING_$ts" forilen@dawx.com fi rm server_$srvid.txt* -f }
mysql> show variables like \'%char%\'; +--------------------------+-----------------------------------+ | Variable_name | Value | +--------------------------+-----------------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /data/mysql/share/mysql/charsets/ | +--------------------------+-----------------------------------+ | ser_group | CREATE TABLE `ser_group` ( `group_id` tinyint(4) NOT NULL auto_increment, `group_name` varchar(100) default \'0\', `group_status` tinyint(4) NOT NULL, `appid` varchar(20) default NULL, PRIMARY KEY (`group_id`) ) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8 |