Score:0

Sendmail and hostname config for another domain

au flag

The following example with fictional names describes my situation:

  • External mail service mailservice.com
  • DNS entry my.server.com points to the server publicly
  • The server should send e-mails from [email protected]

I'm struggling to understand how to name the server (hostname) and what sendmail config to use. Currently, I have the config:

# /etc/hostname
some-random-hostname-without-tld
# /etc/hosts
127.0.0.1   localhost some-random-hostname-without-tld my.server.com
127.0.1.1   some-random-hostname-without-tld

/etc/mail/sendmail.mc contains the minimal config for connecting to the account [email protected] on mailservice.com and defaults otherwise. DNS is setup correctly, i.e. MX, SPF etc. are in place to allow mailservice.com to send and receive mails as yetanotherdomain.com.

While sending e-mails works with this config, doing so takes over 60 seconds. /var/log/mail.info reports that:

  • Relay root@localhost reports immediately: "Message accepted for delivery"
  • Over a minute later, smtp.mailservice.com reports: "stat=Sent (Ok: queued as ...)"

The delay indicates that there is something with my config. As stated above, I'm unsure about which domain to use where. Thus, I have the following questions:

  • What do I need to assign to /etc/hosts as 127.0.0.1 resp. 127.0.1.1?
  • What should the contents of /etc/hostname be? Does it have to be something specific or can /etc/hosts make up for non-FQDN as hostname?
  • Do I need to configure a special host in /etc/mail/sendmail.mc or is use_cw_file good enough in my case?
anx avatar
fr flag
anx
Try `openssl s_client -connect smtp.mailservice.example:25 -starttls smtp -crlf` and do the SMTP commands step by step (starting with `EHLO my.server.example`). It may well be your relay just being slow - or your relay failing to lookup your name or IP address and eventually giving up (I could have checked this if I knew the name.. which is why [you should not obfuscate by nature public names in your posts](https://meta.serverfault.com/questions/963/what-information-should-i-include-or-obfuscate-in-my-posts/6063#6063))
anx avatar
fr flag
anx
Well, do `hostname -s` and `hostname -f` return expected short and fully-qualified names? What does the manual page for or the relevant section of your OS release notes say about how you should configure `/etc/hosts` (on many systems, you can bring it up using `man 5 hosts`)?
au flag
@anx thank you for your answers. The latter helped me get `/etc/hosts` and `/etc/hostname` straight. `man hostname` contains a section "The FQDN" which documents how to set short and full domain name, namely `127.0.1.1 some-random-hostname-without-tld my.server.com`, which causes `hostname -s` and `-f` to work properly. The delay is still there, I will now probe manual connection via openssl.
au flag
Turns out, the mail server does not support STARTTLS. Also, I replaced the `sendmail` setup by `msmtp-mta`, which made configuration significantly easier. Now, mails are sent and delivered instantly.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.