zoukankan      html  css  js  c++  java
  • centos6 利用外部的smpt服务器计划任务发送邮件

    centos可通过修改配置文件以使用外部SMTP服务器,达到不使用sendmail而用外部的smtp服务器发送邮件的目的,

    操作如下:

    一、安装mailx与sendmail

    #  yum -y install mailx  
    # yum -y install sendmail  
    # /etc/init.d/sendmail start  
    # chkconfig sendmail on  

    二、配置发送邮箱的SMPT服务

    三、编辑邮件配置文件/etc/mail.rc,添加外部邮件认证信息

    # vi /etc/mail.rc
    
    set from=xxx@163.com smtp=smtp.163.com
    set smtp-auth-user=xx@163.com smtp-auth-password=xxx smtp-auth=login
    • from是发送的邮件地址
    • smtp是发生的外部smtp服务器的地址
    • smtp-auth-user是外部smtp服务器认证的用户名
    • smtp-auth-password是外部smtp服务器认证的用户密码
    • smtp-auth是邮件认证的方式

    四、测试邮件发送

    mail  -s "`date +%F-%T`" xxx@sohu.com </root/messages.txt

    五、配置计划任务的时候需要将邮件发送信息写入到shell脚本中

    [root@localhost]# cat sendmail.sh 
    #!/bin/bash
    
    cat /root/crawler/Crawler_SecInfoLog/"`date +%F`_Crawler_SecInfoLog.txt" | mail -s "爬虫预警(`date +%F`)" 收信者@163.com
  • 相关阅读:
    vue-常用指令汇总
    vue-插槽和具名插槽
    vue-传值校验
    vue-动态组件
    vue-组件
    zend studio 快捷键收集
    php调试工具firephp
    zend studio插件
    MySQL各个版本区别
    PHP 中 Date 函数与实际时间相差8小时的解决方法
  • 原文地址:https://www.cnblogs.com/tdcqma/p/7825688.html
Copyright © 2011-2022 走看看