• sendmail发送慢的问题


    1.使用python的脚本,发送邮件。代码如下:

    点击查看代码
    [root@ZabbixServerMasterNode ~]# cd /etc/zabbix/alertscripts/
    [root@ZabbixServerMasterNode alertscripts]# cat sendmail.py 
    #!/bin/env python
    #coding:utf-8
     
    import smtplib  
    from email.mime.text import MIMEText  
    from sys import argv
     
    mailto_list=[]
    mail_host="xxx.xxx.cn"
    mail_user="xxx.cn"
    mail_pass="xxxx"
    debug_level=0
     
    def send_mail(to_list,sub,content):
        me=mail_user
        msg = MIMEText(content,_subtype='plain',_charset='utf-8')
        msg['Subject'] = sub  
        msg['From'] = me  
        msg['To'] = ";".join(to_list)
        try:
            server = smtplib.SMTP_SSL(mail_host, 465)
            server.connect(mail_host)
            server.login(mail_user,mail_pass)
            server.sendmail(me,to_list,msg.as_string())
            server.close()
            return True  
        except Exception, e:
            print str(e)
            return False  
    if __name__ == '__main__':
        mailto_list=argv[1].split(';')
        sub=argv[2]
        content=argv[3] 
        send_mail(mailto_list,sub,content)
    
    

    通过调用上述代码,发现特别的慢。
    后面查看是主机定义的新的hostname,但是hosname没有配置。
    通过配置/etc/hosts
    解决邮件发送慢的问题。

  • 相关阅读:
    P5047 [Ynoi2019 模拟赛] Yuno loves sqrt technology II
    P4887 【模板】莫队二次离线(第十四分块(前体))
    SP20644 ZQUERY
    企业战略管理【0612】
    管理经济学【0812】
    商务沟通[0664]
    国际企业管理【0813】
    社区管理【0272】
    战略管理【1059】
    管理沟通【1279】
  • 原文地址:https://www.cnblogs.com/zhangshengdong/p/15868046.html
Copyright © 2020-2023  润新知