Sendmail SMTP "My unqualified hostname" and "My unqualified domain name"

11,221

Typically the fully qualified hostname should be listed first in /etc/hosts, e.g.

192.0.2.0 foo.example.org foo bar

And the system hostname should likewise be fully qualified. Sendmail (and, likely, most any remote MTA it may talk to) will be very unhappy until fully qualified domain names are set everywhere. E.g. my desktop (also my MTA) looks something like:

# sendmail -bt -d0.1 </dev/null
Version 8.15.2
 Compiled with: DNSMAP IPV6_FULL LOG MAP_REGEX MATCHGECOS MILTER
                MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6 NETUNIX NEWDB NIS
                PIPELINING SCANF SOCKETMAP STARTTLS USERDB XDEBUG

============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = foo
  (canonical domain name) $j = foo.example.edu
         (subdomain name) $m = example.edu
              (node name) $k = foo.example.edu
========================================================

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> #
# cat /etc/myname
foo.example.edu
#

Though this (OpenBSD, as shown by the myname file for the hostname) system uses DNS and not the hosts file; the ideal configuration is to use DNS, if that's not possible then get hostname and /etc/hosts right (in particular the $j, $m, and $k values in the above output), and if that's not possible then there are ruleset values you could set.

Share:
11,221

Related videos on Youtube

Matt Jones
Author by

Matt Jones

Updated on September 18, 2022

Comments

  • Matt Jones
    Matt Jones almost 2 years

    Recently, I've been setting up an SMTP mail server for my website (ironfi.st) on a server titled "ironfist-droplet". I'm using the WP-SMTP-MAIL plugin. I have the apache2 server setup up and everything correctly configured. Using: echo "Subject: sendmail test" | sendmail -v [email protected]and the email will send to mine from the server perfectly fine. However, when sending a test email using my WP-MAIL-SMTP plugin it does not send.

    This has led me to believe there may be an issue with the hosts file in /etc/hosts Below is what I have typed into my hosts file:

    127.0.0.1 localhost localhost.localdomain 192.168.1.10 ironfist-droplet ironfist-droplet.ironfi.st ironfi.st

    Below is my mail log file:

    Feb 17 10:59:18 ironfist-droplet sendmail[3223]: v1HFxI2U003223: from=root, size=196, class=0, nrcpts=1, msgid=<201702171559.v1HFxI2U003223@ironfist-droplet>, relay=root@localhost
    Feb 17 10:59:18 ironfist-droplet sm-mta[3225]: v1HFxIYv003225: from=<root@ironfist-droplet>, size=455, class=0, nrcpts=1, msgid=<201702171559.v1HFxI2U003223@ironfist-droplet>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
    Feb 17 10:59:18 ironfist-droplet sendmail[3223]: v1HFxI2U003223: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30196, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v1HFxIYv003225 Message accepted for delivery)
    Feb 17 10:59:18 ironfist-droplet sm-mta[3226]: v1HFxIYv003225: to=<root@ironfist-droplet>, ctladdr=<root@ironfist-droplet> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30682, dsn=2.0.0, stat=Sent
    Feb 17 11:04:35 ironfist-droplet sendmail[3261]: v1HG4ZrO003261: from=root, size=196, class=0, nrcpts=1, msgid=<201702171604.v1HG4ZrO003261@ironfist-droplet>, relay=root@localhost
    Feb 17 11:04:35 ironfist-droplet sm-mta[3263]: v1HG4ZWL003263: from=<root@ironfist-droplet>, size=455, class=0, nrcpts=1, msgid=<201702171604.v1HG4ZrO003261@ironfist-droplet>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
    Feb 17 11:04:35 ironfist-droplet sendmail[3261]: v1HG4ZrO003261: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30196, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v1HG4ZWL003263 Message accepted for delivery)
    Feb 17 11:04:35 ironfist-droplet sm-mta[3264]: v1HG4ZWL003263: to=<root@ironfist-droplet>, ctladdr=<root@ironfist-droplet> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30682, dsn=2.0.0, stat=Sent
    Feb 17 11:04:48 ironfist-droplet sendmail[3269]: v1HG4mAm003269: from=root, size=196, class=0, nrcpts=1, msgid=<201702171604.v1HG4mAm003269@ironfist-droplet>, relay=root@localhost
    Feb 17 11:04:48 ironfist-droplet sm-mta[3271]: v1HG4muh003271: from=<root@ironfist-droplet>, size=455, class=0, nrcpts=1, msgid=<201702171604.v1HG4mAm003269@ironfist-droplet>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
    Feb 17 11:04:48 ironfist-droplet sendmail[3269]: v1HG4mAm003269: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30196, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v1HG4muh003271 Message accepted for delivery)
    Feb 17 11:04:48 ironfist-droplet sm-mta[3272]: v1HG4muh003271: to=<root@ironfist-droplet>, ctladdr=<root@ironfist-droplet> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30682, dsn=2.0.0, stat=Sent
    Feb 18 09:39:26 ironfist-droplet sendmail[9396]: v1IEdQfV009396: from=root, size=14, class=0, nrcpts=2, msgid=<[email protected]>, relay=root@localhost
    Feb 18 09:39:26 ironfist-droplet sm-mta[9397]: v1IEdQrA009397: from=<[email protected]>, size=305, class=0, nrcpts=2, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
    Feb 18 09:39:26 ironfist-droplet sm-mta[9397]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
    Feb 18 09:39:27 ironfist-droplet sm-mta[9397]: v1IEdQrA009397: to=<[email protected]>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=60305, relay=gmail-smtp-in.l.google.com. [173.194.204.26], dsn=2.0.0, stat=Sent (OK 1487428767 a63si3981733qkb.149 - gsmtp)
    Feb 18 09:43:27 ironfist-droplet sm-mta[9397]: v1IEdQrA009397: to=<[email protected]>, delay=00:04:01, xdelay=00:04:00, mailer=esmtp, pri=60305, relay=ironfist-droplet.ironfi.st. [192.168.1.10], dsn=4.0.0, stat=Deferred: Connection timed out with ironfist-droplet.ironfi.st.
    Feb 18 09:43:27 ironfist-droplet sendmail[9396]: v1IEdQfV009396: to=Example,[email protected], ctladdr=root (0/0), delay=00:04:01, xdelay=00:04:01, mailer=relay, pri=60014, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v1IEdQrA009397 Message accepted for delivery)
    Feb 18 09:55:23 ironfist-droplet sm-mta[9426]: v1IEdQrA009397: to=<[email protected]>, delay=00:15:57, xdelay=00:04:15, mailer=esmtp, pri=150305, relay=ironfist-droplet.ironfi.st. [192.168.1.10], dsn=4.0.0, stat=Deferred: Connection timed out with ironfist-droplet.ironfi.st.
    

    As you can see, it's trying to connect to ironfist-droplet.ironfi.st which is what I have put into my /etc/hosts and timing out.

    Below is an attachment of my mail error logs:

    Jan 24 23:21:47 ironfist-droplet sendmail[2417]: My unqualified host name (ironfist-droplet) unknown; sleeping for retry
    Jan 24 23:22:47 ironfist-droplet sendmail[2417]: unable to qualify my own domain name (ironfist-droplet) -- using short name
    Jan 24 23:22:47 ironfist-droplet sm-mta[2486]: My unqualified host name (ironfist-droplet) unknown; sleeping for retry
    Jan 24 23:22:50 ironfist-droplet sm-msp-queue[2491]: My unqualified host name (ironfist-droplet) unknown; sleeping for retry
    Jan 24 23:23:47 ironfist-droplet sm-mta[2486]: unable to qualify my own domain name (ironfist-droplet) -- using short name
    Jan 24 23:23:50 ironfist-droplet sm-msp-queue[2491]: unable to qualify my own domain name (ironfist-droplet) -- using short name
    

    As seen above it's having trouble qualifying the host name and domain name under ironfist-droplet. I'm very new to this, and took the task of setting up an SMTP server as a way to challenge myself and get experience. I'm very new to all this. However, based on this evidence I've been lead to conclude that something is wrong with how I put the information in the hosts file. There are two pieces of info I am positive about though:

    the hostname is ironfist-droplet as hostname -f returns ironfist-droplet and the private ip in the second line is correct as hostname -ireturns 192.168.1.10. I've looked online and haven't been able to find a good comparison of someone's host file to compare to mine.

    If any sees any errors in how I've put in my hosts file or a solution to my issue, please do not hesitate to tell me. All help is appreciated.

    Full hosts file:

    # Your system has configured 'manage_etc_hosts' as True.
    # As a result, if you wish for changes to this file to persist
    # then you will need to either
    # a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
    # b.) change or remove the value of 'manage_etc_hosts' in
    #     /etc/cloud/cloud.cfg or cloud-config from user-data
    127.0.0.1 localhost localhost.localdomain
    192.168.1.10 ironfist-droplet ironfist-droplet.ironfi.st ironfi.st
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    

    Domain name information:

    Version 8.14.4
     Compiled with: DNSMAP LDAPMAP LDAP_REFERRALS LOG MAP_REGEX MATCHGECOS
            MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6 NETUNIX
            NEWDB NIS NISPLUS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
            TCPWRAPPERS USERDB USE_LDAP_INIT XDEBUG
    
    ============ SYSTEM IDENTITY (after readcf) ============
          (short domain name) $w = ironfist-droplet
      (canonical domain name) $j = ironfist-droplet.ironfi.st
             (subdomain name) $m = ironfi.st
                  (node name) $k = ironfist-droplet
    ========================================================
    
  • Matt Jones
    Matt Jones over 7 years
    I've updated my post to contain the information similar to what you have. Yes it does have the proper $w, and $j values etc. As you can see above. Also, I meant to ask about the message above talking about manage_etc_hosts, it tells me to set it to true in the file, yet I've checked both files it refers me to and manage_etc_hosts doesn't even exist as a line in the files! Also, do you know how one could go about enabling DNS for sendmail? I've searched on the internet but I can't find a very straight forward guide to do so!
  • thrig
    thrig over 7 years
    @MattJones your $k is unqualified unlike that on my system; hostname -f returning an unqualified hostname is likely where that is coming from.
  • Matt Jones
    Matt Jones over 7 years
    How is it unqualified? I'm not quite sure I understand. Hostname -f returns the name so how could it be unqualified?
  • thrig
    thrig over 7 years
    ironfist-droplet is totally unqualified, it lacks a domain. Compare foo.example.edu in my output, that's qualified.
  • Matt Jones
    Matt Jones over 7 years
    Okay, how in that case could I change the domain name? Also, I take it from that, in that case the information I have in my host file is incorrect? Sorry again for so many basic question, this is extremely new territory for me, and my own research can only take me so far till I must seek external help. Also if the domain name itself is unqualified how have I been able to connect to ironfi.st which is the website belonging to that domain?
  • thrig
    thrig over 7 years
    Websites are not quite so tied to DNS as a mail agent is. Have you tried using the form of /etc/hosts entry I mentioned in my answer that is different from yours?
  • Matt Jones
    Matt Jones over 7 years
    are you referring to the post you made with the $j and $m values? If so, would that go in /etc/hosts? Because according to the commands to access it, it's coming from /dev/null I still believe I have the information in /etc/hosts incorrectly put in. Also it might be worth mentioning that in my "hostnames" files ironfist-droplet is the hostname if that helps at all.