Link to home
Create AccountLog in
Avatar of pinchasdavid

asked on

Sendmail generates TO: email with FQDN or user@localhost.localdomain instead of

MY problem: Cron and other internal local applications send an email to a local user name JOE without the  Sendmail takes that USER name and tries to send an email TO:, which is the Host name in my /etc/hosts file.  The email fails because it needs to send local mail to

IF I add have this as my first line in the /etc/hosts file   localhost.localdomain localhost, sendmail tacks on joe@localhost.locadomain.  If I put it tacks on   I need to figure a way, to override this behavior.

What I need is get sendmail to not use the localhost.locadomain or the FQDN in the /etc/hosts file, but to use the domain name  I don't know where to configure this?  
I've corrected my /etc/hosts and with all the MASQUERADE options and I can send mail (no problem) to format the address to instead of  WHAT I am unable to do is get sendmail to use my domain name as instead of       localhost.localdomain localhost
65.99.999.9 server1
VERSIONID(`$Id:, v 8.13.8-3 2006-12-13 14:51:49 cowboy Exp $')
dnl #
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
dnl undefine(`confHOST_STATUS_DIRECTORY')dnl        #DAEMON_HOSTSTATS=
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
dnl #
dnl # General defines
dnl #
dnl # SAFE_FILE_ENV: [undefined] If set, sendmail will do a chroot()
dnl #   into this directory before writing files.
dnl #   If *all* your user accounts are under /home then use that
dnl #   instead - it will prevent any writes outside of /home !
dnl #   define(`confSAFE_FILE_ENV',             `')dnl
dnl #
dnl # Daemon options - restrict to servicing LOCALHOST ONLY !!!
dnl # Remove `, Addr=' clauses to receive from any interface
dnl # If you want to support IPv6, switch the commented/uncommentd lines
dnl DAEMON_OPTIONS(`Family=inet6, Name=MTA-v6, Port=smtp, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp')dnl
dnl DAEMON_OPTIONS(`Family=inet6, Name=MSP-v6, Port=submission, Addr=::1')dnl
DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, Addr=')dnl
dnl #
dnl # Bind to external port and enable auth (for relay control)
define(`confAUTH_OPTIONS', `A p')dnl
dnl # Be somewhat anal in what we allow
dnl #
dnl # Define connection throttling and window length
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
dnl #
dnl # Features
dnl #
dnl # The access db is the basis for most of sendmail's checking
FEATURE(`access_db', , `skip')dnl
dnl #
dnl # The greet_pause feature stops some automail bots - but check the
dnl # provided access db for details on excluding localhosts...
FEATURE(`greet_pause', `1000')dnl 1 seconds
dnl #
dnl # Delay_checks allows sender<->recipient checking
FEATURE(`delay_checks', `friend', `n')dnl
dnl #
dnl # If we get too many bad recipients, slow things down...
dnl #
dnl # Stop connections that overflow our concurrent and time connection rates
FEATURE(`conncontrol', `nodelay', `terminate')dnl
FEATURE(`ratecontrol', `nodelay', `terminate')dnl
dnl #
dnl # If you're on a dialup link, you should enable this - so sendmail
dnl # will not bring up the link (it will queue mail for later)
dnl define(`confCON_EXPENSIVE',`True')dnl
dnl #
dnl # Dialup/LAN connection overrides
dnl #
dnl #include(`/etc/mail/m4/dialup.m4')dnl
dnl #added by ALAN June 19, 2008
dnl #the installation via webmin suggested this be added
dnl #
dnl #SSL support
dnl # Virtual User ( aliases) support
dnl # RBL support
FEATURE(`enhdnsbl',`',`"550 spam blocked - see"$&{client_addr}',`t')dnl
dnl #
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
dnl #
dnl # The following example makes mail from this host and any additional
dnl # specified domains appear to be sent from
dnl #
dnl #
dnl # masquerade not just the headers, but the envelope as well
dnl #
dnl #
dnl # masquerade not just, but @* as well
dnl #
dnl #
dnl #
dnl # Default Mailer setup

Open in new window

Avatar of .
Flag of Solomon Islands image

Hi, Have you tried adding an entry to /etc/mail/virtusertable ?

You better set proper domain on Your box(/etc/sysconfig/network for RH-like systems)
the commands
should return valid names, instead of localhost.localdomain

Or tell the sendmail it's domainname by hand. Like
Avatar of pinchasdavid


I've seen this file mentioned before; /etc/sysconfig/network, but I do not have this file on my system.  I am using ubuntu.
Also, your article link mentions adding;

Cwlocalhost mil-gw

Where do these lines get added within  In the past I added these lines under the MASQUERADE lines and it did not
resolve the problem.
Thanks for your help!
just replace localhost.localdomain in following string in your file with

i.e instead



thats all
and don't forget to run makr in /etc/mail to rebuild .cf files
/etc/init.d/sendmail reload
Implemented both your suggestions:

Cwlocalhost    AND:

Also tried:

Cwlocalhost    AND:


same behavior, 3 days of this and I'm going nuts.
Ah, the article was saying about more than local domain name.

in find and modify following, rollback Your previous changes
# my official domain name
# ... define this only if sendmail cannot automatically determine your domain

After You change, You have to rebuild the config: make

But really, You should set system wide host and domainname!
You said: You should set system wide host and domainname.
System wide host is set in /etc/hosts
I don't know where domainname is set:  I see postings mention
/etc/sysconf/network  but that is not what ubuntu uses and I'm
aware of what the equiv. config file is in ubuntu.  Do you know?

Avatar of ravenpl
Flag of Poland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Backed out previous changes to and Added:


No change in behavior.   localhost.localdomain localhost server

My mail server as named in DNS is
My hostname is
I also have numerous virtualhosts that I specify in my hosts file.

Is there any I should try in my hosts config???
check that your have

or you has


and add following lines into /etc/mail/local-host-names

I think on ubuntu hostname set in /etc/HOSTNAME grep init scripts  for 'hostname' command (start from /etc/rc.d/rc.sysinit or what ever you have in your /etc/inittab)
usually it is command like
hostname -F /etc/HOSTNAME
hostname $HOSTNAME
record in /etc/hosts does not change your hostname.

I reread you question and think what you actually need is to use


in to add you default domain to unqualified user names
I was curious if you ever got your correct answer to this. I have the same issue.