标签:
1、配置sendmail
vi /etc/mail.rc
加入以下行
set bsdcompat
set from=邮件用户名@domain.com smtp=smtp.126.com set smtp-auth-user=邮件用户名 smtp-auth-password=邮箱密码 set smtp-auth=login
2、检查commands.cfg
################################################################################ # # SAMPLE NOTIFICATION COMMANDS # # These are some example notification commands. They may or may not work on # your system without modification. As an example, some systems will require # you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below. # ################################################################################ # ‘notify-host-by-email‘ command definition define command{ command_name notify-host-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s " ** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ } # ‘notify-service-by-email‘ command definition define command{ command_name notify-service-by-email command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditi onal Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ }
这是正确的命令配置,其中最重要的就是/bin/mail后边的命令配置
3、mqueue
ls /var/spool/mqueue
这个目录存储的是邮件发送队列,
/usr/lib/sendmail -bp
若屏幕显示为“Mail queue is empty” 的信息,表示mail 已送出。
6、发送测试邮件
mail -s "test" luoyelin1989@126.com <content.txt
content.txt为邮件内容
标签:
原文地址:http://www.cnblogs.com/wuxie1989/p/5505766.html