Link to home
Create AccountLog in
Avatar of pinchasdavid
pinchasdavid

asked on

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

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

IF I add have this as my first line in the /etc/hosts file     127.0.0.1   localhost.localdomain localhost, sendmail tacks on joe@localhost.locadomain.  If I put server.mydomain.com it tacks on joe@server.mydomain.com.   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 @mydomain.com.  I don't know where to configure this?  
 
I've corrected my /etc/hosts and sendmail.mc with all the MASQUERADE options and I can send mail (no problem) to format the address to FROMuser@mydomain.com instead of FROMuser@server.mydomain.com.  WHAT I am unable to do is get sendmail to use my domain name as TOuser@mydomain.com instead of TOuser@server.domain.com.
 
127.0.0.1       localhost.localdomain localhost
65.99.999.9     server1.anydomain.com server1
 
define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail.mc, v 8.13.8-3 2006-12-13 14:51:49 cowboy Exp $')
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
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
FEATURE(`no_default_msa')dnl
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=127.0.0.1')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
define(`confPRIVACY_FLAGS',dnl
`needmailhelo,needexpnhelo,needvrfyhelo,restrictqrun,restrictexpand,nobodyreturn,authwarnings')dnl
dnl #
dnl # Define connection throttling and window length
define(`confCONNECTION_RATE_THROTTLE', `15')dnl
define(`confCONNECTION_RATE_WINDOW_SIZE',`10m')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...
define(`confBAD_RCPT_THROTTLE',`3')dnl
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
include(`/etc/mail/m4/provider.m4')dnl
dnl #added by ALAN June 19, 2008
dnl #the installation via webmin suggested this be added
dnl #
include(`/etc/mail/sasl/sasl.m4')dnl
dnl #SSL support
include(`/etc/mail/tls/starttls.m4')dnl
dnl # Virtual User (user@somedomain.com aliases) support
FEATURE(`virtusertable')dnl
FEATURE(`use_cw_file')dnl
FEATURE(`use_ct_file')dnl
dnl # RBL support
FEATURE(`enhdnsbl',`bl.spamcop.net',`"550 spam blocked - see http://spamcop.net/bl.shtml?"$&{client_addr}',`t')dnl
dnl #
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
LOCAL_DOMAIN(`localhost.localdomain')dnl
dnl #
dnl # The following example makes mail from this host and any additional
dnl # specified domains appear to be sent from mydomain.com
dnl #
MASQUERADE_AS(`mydomain.com')dnl
dnl #
dnl # masquerade not just the headers, but the envelope as well
dnl #
FEATURE(masquerade_envelope)dnl
dnl #
dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl #
FEATURE(masquerade_entire_domain)dnl
dnl #
MASQUERADE_DOMAIN(localhost.localdomain)dnl
MASQUERADE_DOMAIN(server.mydomain.com)dnl
MASQUERADE_DOMAIN(mail.mydomain.com)dnl
MASQUERADE_DOMAIN(mydomain.com)dnl
MASQUERADE_DOMAIN(localhost)dnl
dnl #
dnl # Default Mailer setup
MAILER_DEFINITIONS
MAILER(`local')dnl
MAILER(`smtp')dnl

Open in new window

Avatar of .
.
Flag of Solomon Islands image

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

like

johan@mydomainname.co.uk      johan@mail.mydomainname.co.uk
You better set proper domain on Your box(/etc/sysconfig/network for RH-like systems)
the commands
hostname
domainname
should return valid names, instead of localhost.localdomain

Or tell the sendmail it's domainname by hand. Like http://www.unix.com.ua/orelly/networking/tcpip/ch10_07.htm
Avatar of pinchasdavid
pinchasdavid

ASKER

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 mil-gw.nuts.com
DSrelay.nuts.com

Where do these lines get added within sendmail.mc?  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 sendmail.mc file with mydomain.com

i.e instead
LOCAL_DOMAIN(`localhost.localdomain')dnl

put

LOCAL_DOMAIN(`mydomain.com')dnl

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

Cwlocalhost server.mydomain.com
DSmydomain.com    AND:

Also tried:

Cwlocalhost mydomain.com
DSmydomain.com    AND:

LOCAL_DOMAIN(`mydomain.com')dnl

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

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

After You change sendmail.mc, 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?

ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

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

Dj$w.mydomain.COM

No change in behavior.

127.0.0.1   localhost.localdomain localhost
12.12.12.12 server.mydomain.com server

My mail server as named in DNS is mail.mydomain.com
My hostname is server.tailofthelion.com
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 sendmail.mc have
FEATURE(`use_cw_file')

or you sendmail.cf has

Fw/etc/mail/local-host-names

and add following lines into /etc/mail/local-host-names
server.mydomain.com
mail.mydomain.com

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
or
hostname $HOSTNAME
record in /etc/hosts does not change your hostname.

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

FEATURE(always_add_domain,`mydomain.com')dnl

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