zoukankan      html  css  js  c++  java
  • CentOS 6.5 通过命令行安装发送邮件

    1.安装sendmail:

    yum install sendmail

    2.安装mailx:

    yum install mailx -y

    3.编辑发送的配置文件:

    vi /etc/mail.rc
    #在最后添加以下配置:
    set from="991769422@qq.com" smtp="smtp.qq.com"
    set smtp-auth-user="991769422@qq.com" smtp-auth-password="******"
    set smtp-auth=login

    4.测试邮件发送:

    #1)  无邮件正文
      mail -s "主题"  收件地址
      mail -s "测试"  991769422@qq.com
     
    
    #2) 有邮件正文
    
     mail -s "主题"  收件地址< 文件(邮件正文.txt)
     mail -s "邮件主题"  991769422@qq.com < /data/test.txt
     echo "邮件正文" | mail -s 邮件主题  收件地址
     echo "邮件正文内容" | mail -s "邮件主题"  991769422@qq.com
     cat test.txt | mail -s 邮件主题  收件地址 
     cat  /data/test.txt | mail -s "邮件主题"  991769422@qq.com
     
    
    #3)  带附件
     mail -s "主题"  收件地址  -a 附件 < 文件(邮件正文.txt) 
     mail -s "邮件主题"  991769422@qq.comm -a /data/test.tar.gz < /data/test.txt

    6.脚本文件:

    #*************************************************************************
    #  FileName     :               disk_capatiy_alarm.sh 
    #*************************************************************************
    #  Author       :               joshua317
    #  CreateDate   :               2017-09-11
    #  Description  :               this script is mointoring the linux disk
    #                               capacity, if disk used more than 80%,
    #                               then it will send a alarm email
    #*************************************************************************
    
    #!/bin/bash
    host=`hostname`
    for d in `df -P| awk '{print $5}' | sed 's/%//g'`
     do
       if [[ "$d" =~ ^[0-9]*$ ]]&&[ $d -gt 80 ];then
       #echo $d
       echo $host"'s disk will unAvail, please process as quickly as possible" | mail -s "the disk will run out" 991769422@qq.com
       exit;   
       fi
     done

    7.定时脚本

    #磁盘空间检查,每1小时执行一次
    crontab -e
    * */1 * * * /bin/sh /usr/local/shell/disk_capatiy_alarm.sh
  • 相关阅读:
    Error Correct System(模拟)
    Pasha and String(思维,技巧)
    Vitaliy and Pie(模拟)
    Old Sorting(转化成单调序列的最小次数,置换群思想)
    Segment(技巧 相乘转换成相加 + java)
    Conquering Keokradong && Get the Containers(二分)
    Handshakes(思维) 2016(暴力)
    Dice Notation(模拟)
    “玲珑杯”郑州轻工业学院第八届ACM程序设计大赛暨河南高校邀请赛-正式赛(总结)
    MySQL安装-二进制软件包安装
  • 原文地址:https://www.cnblogs.com/joshua317/p/7506404.html
Copyright © 2011-2022 走看看