18

and yes, I have

127.0.0.1   localhost myhost.mydomain.eu myhost.domain2.eu localhost.localdomain
127.0.1.1   myhost

in hosts file. What is wrong? Sendmail started to put this error into log.

May 9 19:08:54 myhost sm-mta[17103]: unable to qualify my own domain name (myhost) -- using short name

Is this configuration OK?

AnFi
  • 5,883
  • 1
  • 12
  • 26
  • What is "this error"? – cuonglm May 09 '13 at 17:29
  • unable to qualify my own domain name (myhost) — using short name –  May 09 '13 at 17:32
  • I didn't receive this error at the beginning - It must be that I deleted something from somewhere –  May 09 '13 at 17:33
  • @Gnouc however sendmail works almost entirely OK –  May 09 '13 at 17:34
  • "unable to qualify my own domain name (myhost)" - What tool you use to troubleshoot? Ping command? – cuonglm May 09 '13 at 17:57
  • this is error from mail.err –  May 09 '13 at 18:02
  • Would you mind posting the error and your sendmail config? – cuonglm May 09 '13 at 18:04
  • @Gnouc this is this error, I added to question. (possibly I've just found solution) –  May 09 '13 at 18:06
  • 3
    This question and its answer were exactly what I was looking for, so it should be reopened. The title states the question correctly. The body text asks whether the answer lies in modifying /etc/hosts, and if so, how. The answer makes it clear that this is indeed the case. The body text could be cleared up a little. – reinierpost Oct 07 '15 at 11:00
  • In CentOS 6, this error can be found in /var/log/maillog and the solution (which could be explained better) makes a big difference. I've been working on Dovecot+Postfix+Sendmail for 2 days now and thanks to this crazy question, this is the first time I'm able to email my own server. Goodbye Gmail ;-) – PJ Brunet Feb 12 '17 at 11:08

2 Answers2

31

Sendmail: short host name to FQDN via /etc/hosts entry

Reorder your /etc/hosts file entries:

127.0.0.1   localhost localhost.localdomain
127.0.1.1   myhost.mydomain.eu myhost.domain2.eu myhost

It should qualify myhost to myhost.mydomain.eu (the leftmost name in /etc/hosts line with myhost)

AnFi
  • 5,883
  • 1
  • 12
  • 26
  • what about localhost? might be after this? why? what are the rules? –  May 09 '13 at 18:19
  • @Andzrej A.Filip really this way? I have seen many configuration but not this one, can you say anything about it? –  May 09 '13 at 18:31
  • this works! great. However I had changed 127.0.0.1 localhost localhost.localdomain to 127.0.0.1 localhost myhost.mydomain.eu before because my SMTP has introduced himself as localhost.localdomain : I am afraid this problem will come back now. What do you think about it? –  May 09 '13 at 18:38
  • 1
    If you want to change how your SMTP server announces itself change the $j macro as [described here](http://serverfault.com/a/505546/25640) – adamo May 09 '13 at 18:42
  • 1
    As I understand when sendmail uses /etc/hosts file to get Fully Quallified Domain Name (FQDN) it gets leftmost **name** from line with the short host name. – AnFi May 09 '13 at 18:44
  • I have tested and it looks like indeed myhost.mydomain.eu is taken to introducing themself by my sendmail (I didn't change $j macr but thanks adamo), previously I was listed on Spamhaus due to my SMTP EHLOong as localhost.localdomain. THANK YOU –  May 09 '13 at 18:48
  • IMHO changing $j (solution for sendmail ONLY) should not be be first choice in most situations. – AnFi May 09 '13 at 18:53
0

The issue can be resolved by entering the exchange server and mail router ip and domain information in your /etc/hosts file. See below:

#######mail server

ipofexchangeserver   exchangeservername.domain.local  mailhost

ipofmailrouter       mailrouter mailrouter.domain 

Example:

172.18.18.400    sampleexvs   sampleexvs.samplegroup.com   mailhost

172.18.68.432    mailrouter   mailrouter.samplegroup.net
Patrick Mevzek
  • 9,273
  • 7
  • 29
  • 42