How do you specify the FQDN (Host and Domain Name) that a mail server presents itself as in HELO/EHLO when sending outgoing email with sendmail?

3 Answers 3


I added the following in sendmail.mc:

define(`confDOMAIN_NAME', `mail.foo.com')dnl

and then:

m4 sendmail.mc > sendmail.cf
service sendmail restart

I also verified that this worked with the email verifier service at http://www.port25.com/domainkeys/ ([email protected]). Neat service, you send it an email and it replies to the from header with information about your SPF, Domain Keys, etc...

  • Word of caution (perhaps common sense but I'll mention it anyway). The value for confDOMAIN_NAME should NOT be an email domain. Setting it to that will cause sendmail to reject messages because it thinks the mailboxes are (or should be) local.
    – Mike B
    Jul 7, 2016 at 17:29
  • This is not directly related to the question, but for anyone that arrives here looking for info on how to prevent your foo.localdomain from showing up in email headers, try using the MASQUERADE functions to ensure your sent mail doesn't contain a local machine name in the headers. I got that from here (lines must be entered before any MAILER entries) cyberciti.biz/tips/… Feb 7, 2018 at 16:53
  • mail.foo.com is it our domain name?
    – Yohanes AI
    Aug 30, 2018 at 9:29

For completeness - one can also use


if one needs more absolute control (e.g. in a freeb-bsd jail it may be desirable to have the confDOMAIN_NAME and MASQUERADE_AS set very different than the HELO/EHLO names.


define(`confSMTP_LOGIN_MSG', `$j; $b')dnl

Also configure /etc/hosts file like below

xxx.xxx.xxx.xxx           server server.yourdomain.com server                 server server.yourdomain.com server

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .