Configure sendmail to accept mail from subdomain only.

I'd like to have all my cron mail sent to my gmail account. i have a domain with MX entries configured accordingly. the mail for that domain works well otherwise.

I have a host at sub.domain.com. no matter what configuration changes i try to make to sendmail, it keeps accepting/routing mail to user@domain.com. I would like it to only accept mail/local mail for user@sub.domain.com and have the other emails sent according to the MX entries.

I've tried changing define(`confDOMAIN_NAME', `sub.domain.com')dnl in the .mc
using local-host-names
adding Cwsub.domain.com to the .cf

make all install restart

but so far have been unsuccessful. any help would be appreciated.
 
I haven't tried it before but you could dig around this feature :
FEATURE(`relay_hosts_only')
and create the file /etc/mail/relay-domains with only your sub.domain.com in it.
 
I've tried changing define(`confDOMAIN_NAME', `sub.domain.com')dnl in the .mc using local-host-names adding Cwsub.domain.com to the .cf
Don't edit .cf files, that header isn't included for no reason.

You say that you edited .mc files, what files did you edit exactly? Normally running make install for the first time will generate .mc and .cf files which are named after your host. Those are the files you'd need.

Also look into local-host-names, did you edit that file as well? That's the config file where you'd normally define any local names which Sendmail should honor.
 
Don't edit .cf files, that header isn't included for no reason.

You say that you edited .mc files, what files did you edit exactly? Normally running make install for the first time will generate .mc and .cf files which are named after your host. Those are the files you'd need.

Also look into local-host-names, did you edit that file as well? That's the config file where you'd normally define any local names which Sendmail should honor.

Thanks for your reply,

added define(`confDOMAIN_NAME', `sub.domain.com')dnl to both sub.domain.com.submit.mc and sub.domain.com.mc which are the files used in the makefile per hostname;

SENDMAIL_MC!= hostname
SENDMAIL_MC:= ${SENDMAIL_MC}.mc

correct, you should not edit the .cf ... it was a suggestion from stackoverflow which did not help.

i've created local-host-names and added sub.domain.com ... but from what i understand that is for supplemental domains.

and currently its still accepting mail for user@domain.com instead of using the MX.
 
I haven't tried it before but you could dig around this feature :
FEATURE(`relay_hosts_only')
and create the file /etc/mail/relay-domains with only your sub.domain.com in it.
added FEATURE(`relay_hosts_only') to both sub.domain.com.submit.mc and sub.domain.com.mc

and defined sub.domain.com in relay-domains.

no luck
 
Very good question Lamia.

What you're describing teksimian doesn't make much sense unless you somehow used a specific hostname or added your own specific configuration. By default Sendmail will only accept mail for the current hostname and that's it, it would most definitely not "just" also accept mail for a domain, even if that is its own domain name.

My LAN server (named zefiris.intranet.lan) also relies on Sendmail and it would only accept mail for the domain after I added said name to /etc/local-host-names. /etc/zefiris.intranet.lan.mc only defines regular things such as access lists, the use of blacklistd and my local Cyrus mail processor.

Which brings me to: what did you use for the DOMAIN option?
 
[user@sub /etc/mail]$ grep DOMAIN *
freebsd.mc:DOMAIN(generic)
sub.domain.com.mc:DOMAIN(generic)
sub.domain.com.mc:define(`confDOMAIN_NAME', `sub.domain.com')dnl
sub.domain.com.submit.mc:define(`confDOMAIN_NAME', `sub.domain.com')dnl



[user@sub /etc/mail]$ tail -f /var/log/maillog
...
[user@sub /etc/mail]$ sudo make all install restart
install -m 444 sub.domain.com.cf /etc/mail/sendmail.cf
install -m 444 sub.domain.com.submit.cf /etc/mail/submit.cf
Restarting: sendmailOct 18 19:11:59 sub sm-mta[26550]: restarting /usr/sbin/sendmail due to signal
sendmail-clientmqueueOct 18 19:11:59 sub sm-msp-queue[26551]: restarting /usr/sbin/sendmail due to signal
.
[user@sub /etc/mail]$ Oct 18 19:12:00 sub sm-mta[26600]: starting daemon (8.15.2): SMTP+queueing@00:30:00
Oct 18 19:12:00 sub sm-msp-queue[26601]: starting daemon (8.15.2): queueing@00:30:00

[user@sub /etc/mail]$ mail [EMAIL]user@domain.com[/EMAIL]
Subject: test321
321
123
.
EOT
[user@sub /etc/mail]$ Oct 18 19:12:22 sub sendmail[26605]: w9INCM7E026605: from=user, size=47, class=0, nrcpts=1, msgid=<[EMAIL]201810182312.w9INCM7E026605@sub.domain.com[/EMAIL]>, relay=user@localhost
Oct 18 19:12:27 sub sendmail[26605]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1.2, verify=FAIL, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Oct 18 19:12:27 sub sm-mta[26606]: STARTTLS=server, relay=localhost [127.0.0.1], version=TLSv1.2, verify=NO, cipher=DHE-RSA-AES256-GCM-SHA384, bits=256/256
Oct 18 19:12:27 sub sm-mta[26606]: w9INCREM026606: from=<[EMAIL]user@sub.domain.com[/EMAIL]>, size=379, class=0, nrcpts=1, msgid=<[EMAIL]201810182312.w9INCM7E026605@sub.domain.com[/EMAIL]>, proto=ESMTPS, daemon=Daemon0, relay=localhost [127.0.0.1]
Oct 18 19:12:27 sub sendmail[26605]: w9INCM7E026605: to=[EMAIL]user@domain.com[/EMAIL], ctladdr=user (1001/1001), delay=00:00:05, xdelay=00:00:05, mailer=relay, pri=30047, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (w9INCREM026606 Message accepted for delivery)
Oct 18 19:12:27 sub sm-mta[26607]: w9INCREM026606: to=<[EMAIL]user@domain.com[/EMAIL]>, ctladdr=<[EMAIL]user@sub.domain.com[/EMAIL]> (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30714, relay=local, dsn=2.0.0, stat=Sent

You have new mail in /var/mail/user
[user@sub /etc/mail]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/mail/user": 3719 messages 1 new 3719 unread
...
>N3719 [EMAIL='user@sub.aftre.n']user@sub.domain.c[/EMAIL]om Thu Oct 18 19:12 20/766 "test321"
&
Message 3719:
From [EMAIL]user@sub.domain.com[/EMAIL] Thu Oct 18 19:12:27 2018
Date: Thu, 18 Oct 2018 19:12:22 -0400 (EDT)
From: Firstname Lastname <[EMAIL]user@sub.domain.com[/EMAIL]>
To: [EMAIL]user@domain.com[/EMAIL]
Subject: test321

321
123

...

[user@sub /etc/mail]$ hostname
sub.domain.com

thanks for your help so far!
 
Is your domain name same as your hostname & vice versa?

Most mail agents require that even though some agents don't require a reverse lookup.

output edited, i apologize.

[user@sub /etc/mail]$ hostname
sub.domain.com
[user@sub /etc/mail]$ host domain.com
domain.com has address 123.123.123.123
domain.com mail is handled by 15 eforward4.registrar-servers.com.
domain.com mail is handled by 10 eforward2.registrar-servers.com.
domain.com mail is handled by 10 eforward3.registrar-servers.com.
domain.com mail is handled by 10 eforward1.registrar-servers.com.
domain.com mail is handled by 20 eforward5.registrar-servers.com.

 
Very good question Lamia.

What you're describing teksimian doesn't make much sense unless you somehow used a specific hostname or added your own specific configuration. By default Sendmail will only accept mail for the current hostname and that's it, it would most definitely not "just" also accept mail for a domain, even if that is its own domain name.

My LAN server (named zefiris.intranet.lan) also relies on Sendmail and it would only accept mail for the domain after I added said name to /etc/local-host-names. /etc/zefiris.intranet.lan.mc only defines regular things such as access lists, the use of blacklistd and my local Cyrus mail processor.

Which brings me to: what did you use for the DOMAIN option?

any thoughts on the above posted logs?
 
Back
Top