码迷,mamicode.com
首页 > 系统相关 > 详细

linux学习-mail发送邮件(mail不能发邮件)

时间:2016-05-12 23:51:04      阅读:343      评论:0      收藏:0      [点我收藏+]

标签:

主机:centos 7 ,

安装sendmail,启动sendmail,一般就可以了,但是有些同学为什么不行,就是启不动出现如下的情况!那现在如何解决。

yum install sendmail
systemctl start sendmail.service
systemctl status sendmail.service
● sendmail.service - Sendmail Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/sendmail.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-05-08 12:22:58 CST; 1min 33s ago
  Process: 9727 ExecStart=/usr/sbin/sendmail -bd $SENDMAIL_OPTS $SENDMAIL_OPTARG (code=exited, status=0/SUCCESS)
  Process: 9722 ExecStartPre=/etc/mail/make aliases (code=exited, status=0/SUCCESS)
  Process: 9720 ExecStartPre=/etc/mail/make (code=exited, status=0/SUCCESS)
 Main PID: 9730 (sendmail)
   CGroup: /system.slice/sendmail.service
           └─9730 sendmail: accepting connection

May 08 12:21:58 iZ28xev9g2sZ systemd[1]: Starting Sendmail Mail Transport Agent...
May 08 12:21:58 iZ28xev9g2sZ sendmail[9727]: My unqualified host name (iZ28xev9g2sZ) unknown; sleeping for retry
May 08 12:22:58 iZ28xev9g2sZ sendmail[9727]: unable to qualify my own domain name (iZ28xev9g2sZ) -- using short name
May 08 12:22:58 iZ28xev9g2sZ systemd[1]: PID file /run/sendmail.pid not readable (yet?) after start.
May 08 12:22:58 iZ28xev9g2sZ sendmail[9730]: starting daemon (8.14.7): SMTP+queueing@01:00:00
May 08 12:22:58 iZ28xev9g2sZ systemd[1]: Started Sendmail Mail Transport Agent.
解决方法:其实就是你的主机没有设置hostname

mail发送邮件,默认调用的是sendmail,sendmail发送邮件,必须设置hostname,而hostname不能是一串字符串,而必须是格式正确的域名,例如mail.tome178.com

所以我们的解决方法是修改hostname,一种是临时的,一种是永久的

一般我们可以设置临时的

hostname mail.tome178.com

永久的修改/etc/sysconfig/network

hostname=mail.tome178.com //主机名(没有这行?那就添加这一行吧) 
然后运行

hostname mail.tome178.com

然后重启sendmail就可以发送邮件了

● sendmail.service - Sendmail Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/sendmail.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2016-05-08 12:39:48 CST; 16min ago
  Process: 9939 ExecStart=/usr/sbin/sendmail -bd $SENDMAIL_OPTS $SENDMAIL_OPTARG (code=exited, status=0/SUCCESS)
  Process: 9933 ExecStartPre=/etc/mail/make aliases (code=exited, status=0/SUCCESS)
  Process: 9932 ExecStartPre=/etc/mail/make (code=exited, status=0/SUCCESS)
 Main PID: 9942 (sendmail)
   CGroup: /system.slice/sendmail.service
           └─9942 sendmail: accepting connections

May 08 12:41:12 mail.tome178.com sendmail[9965]: u484fBCq009965: from=<root@mail.tome178.com>, si....1]
May 08 12:41:13 mail.tome178.com sendmail[9967]: STARTTLS=client, relay=163mx01.mxmail.netease.co...256
May 08 12:41:14 mail.tome178.com sendmail[9967]: STARTTLS=client, relay=163mx03.mxmail.netease.co...256
May 08 12:41:14 mail.tome178.com sendmail[9967]: u484fBCq009965: to=<tomyjohn@163.com>, ctladdr=<...74)
May 08 12:41:21 mail.tome178.com sendmail[9971]: u484fKXx009971: from=<root@mail.tome178.com>, si....1]
May 08 12:41:21 mail.tome178.com sendmail[9973]: STARTTLS=client, relay=mx3.qq.com., version=TLSv...128
May 08 12:41:24 mail.tome178.com sendmail[9973]: u484fKXx009971: to=<tomyjohn@qq.com>, ctladdr=<r...s )
May 08 12:54:08 mail.tome178.com sendmail[9988]: u484s8IS009988: from=<root@mail.tome178.com>, si....1]
May 08 12:54:09 mail.tome178.com sendmail[9990]: STARTTLS=client, relay=mx3.qq.com., version=TLSv...128
May 08 12:54:09 mail.tome178.com sendmail[9990]: u484s8IS009988: to=<tomyjohn@qq.com>, ctladdr=<r...s )
Hint: Some lines were ellipsized, use -l to show in full.





linux学习-mail发送邮件(mail不能发邮件)

标签:

原文地址:http://blog.csdn.net/tomyjohn/article/details/51345148

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!