zoukankan      html  css  js  c++  java
  • Linux下使用sendmail发送邮件

    现在每天需要将统计数据发送给指定的人员。

    使用原始手工的方式每天发送很麻烦,于是想改成一个定时任务,让服务器自动发送。

    技术告诉我说他有写过sendmail的一个脚本。

    我尝试使用了一下,发现 service sendmail status的时候,总是会出现如下东西。我不知道是不是我的误操作导致的邮件发送阻塞。

    Oct  5 07:00:01 sgadmin sendmail[30731]: u94N01EY030730: to=<root@sgadmin>, ctladdr=<root@sgadmin> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=138838, dsn=2.0.0, stat=Sent
    Oct  5 07:00:34 sgadmin sendmail[30736]: My unqualified host name (sgadmin) unknown; sleeping for retry
    Oct  5 07:01:34 sgadmin sendmail[30736]: unable to qualify my own domain name (sgadmin) -- using short name
    Oct  5 08:00:01 sgadmin sendmail[30736]: u94N1YKI030736: from=root, size=446, class=-60, nrcpts=1, msgid=<201610042301.u94N1YKI030736@sgadmin>, relay=root@localhost
    Oct  5 08:00:01 sgadmin sendmail[31179]: u950017D031179: from=<root@sgadmin>, size=667, class=-60, nrcpts=1, msgid=<201610042301.u94N1YKI030736@sgadmin>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
    Oct  5 08:00:01 sgadmin sendmail[30736]: u94N1YKI030736: to=root, ctladdr=root (0/0), delay=00:58:27, xdelay=00:00:00, mailer=relay, pri=138446, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (u950017D031179 Message accepted for delivery)
    

     

    然后我让sendmail服务重启了一下。这下可就不对了

    1.启动时间很长(时间长估计是因为有错误的原因)

    2.启动后报错

    去查看log日志(cat /var/log/maillog),报错信息如下所示

    Oct  7 12:00:02 sgadmin sendmail[10425]: u97401JN010424: to=<root@sgadmin>, ctladdr=<root@sgadmin> (0/0), delay=00:00:01, xdelay=00:00:00, mailer=local, pri=138838, dsn=2.0.0, stat=Sent
    Oct  7 12:00:35 sgadmin sendmail[10430]: My unqualified host name (sgadmin) unknown; sleeping for retry
    Oct  7 12:01:35 sgadmin sendmail[10430]: unable to qualify my own domain name (sgadmin) -- using short name
    Oct  7 12:21:34 sgadmin sendmail[10653]: My unqualified host name (sgadmin) unknown; sleeping for retry
    Oct  7 12:22:34 sgadmin sendmail[10653]: unable to qualify my own domain name (sgadmin) -- using short name
    Oct  7 12:22:34 sgadmin sendmail[10660]: starting daemon (8.14.7): SMTP+queueing@01:00:00
    Oct  7 12:22:34 sgadmin sm-msp-queue[10673]: My unqualified host name (sgadmin) unknown; sleeping for retry
    Oct  7 12:23:34 sgadmin sm-msp-queue[10673]: unable to qualify my own domain name (sgadmin) -- using short name
    Oct  7 12:23:34 sgadmin sm-msp-queue[10678]: starting daemon (8.14.7): queueing@01:00:00
    Oct  7 12:36:32 sgadmin sendmail[10877]: My unqualified host name (sgadmin) unknown; sleeping for retry
    Oct  7 12:37:32 sgadmin sendmail[10877]: unable to qualify my own domain name (sgadmin) -- using short name
    Oct  7 12:37:32 sgadmin sendmail[10882]: starting daemon (8.14.7): SMTP+queueing@01:00:00
    Oct  7 12:37:32 sgadmin sm-msp-queue[10894]: My unqualified host name (sgadmin) unknown; sleeping for retry
    Oct  7 12:38:32 sgadmin sm-msp-queue[10894]: unable to qualify my own domain name (sgadmin) -- using short name
    Oct  7 12:38:32 sgadmin sm-msp-queue[10912]: starting daemon (8.14.7): queueing@01:00:00

    错误很明显。意识是找不到sgadmin这个域名。

    于是乎就想到修改 /etc/hosts 文件

    加上 ip sgadmin 之后重启sendmail服务,仍然报同样的错

    这让我很费解啊,我已经加上了啊,难道说没有生效?

    然后找到一篇文章,文章说 FQDN里面规定域名必须用"."结尾

    于是我又一次修改hosts 意 ip sgadmin. sgadmin 这样的方式

    然后重启sendmail服务,一切正常,启动速度也很快,估计是少了寻找domain的时间

    博文地址:http://blog.csdn.net/taolinke/article/details/4496316

    其实这里我还有疑问。那个技术之前也没有在hosts中添加sgadmin这个域名,为什么他能够正常的发送邮件???

    再继续研究一下,未完待续。

  • 相关阅读:
    New version of VS2005 extensions for SharePoint 3.0
    QuickPart : 用户控件包装器 for SharePoint Server 2007
    随想
    发布 SharePoint Server 2007 Starter Page
    如何在SharePoint Server中整合其他应用系统?
    Office SharePoint Server 2007 中文180天评估版到货!
    RMS 1.0 SP2
    SharePoint Server 2007 Web内容管理中的几个关键概念
    如何为已存在的SharePoint站点启用SSL
    Some update information about Office 2007
  • 原文地址:https://www.cnblogs.com/0xcafedaddy/p/5935786.html
Copyright © 2011-2022 走看看