Solved

How can i restrict user not send mail to other domain. Only they can send mail to my domain? i am using sendmail/

Posted on 2009-07-10
10
666 Views
Last Modified: 2013-12-18
How can i restrict user not send mail to other domain. Only they can send mail to my domain? i am using sendmail/
0
Comment
Question by:aloknet21
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 27

Expert Comment

by:Nopius
ID: 24823755
Turn off mail relay.
edit /etc/mail/access file
remove these lines (and all other RELAY or OK lines):
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY

and rebuild access.db:
cd /etc/mail
make access.db

then they will be able to send only to your local domain, that is served by this server.
0
 
LVL 28

Expert Comment

by:Jan Springer
ID: 24825223
The real answer, without a milter, is that you cannot.

You can block "To:", "From:", etc by username and/or IP but there is not regular expression that says "block From except To and From".

You also need to consider that the client may not even use your SMTP server.

Please do not do what was recommended above.  You need to be able to receive messages that originate locally (like daily logwatch information, local bounces, etc).

Defining what email for which domain your server accepts (as suggested above) is located in /etc/mail/local-host-names.  This is not applicable to your question.
0
 
LVL 27

Expert Comment

by:Nopius
ID: 24830071
_jesper_, hi.

>  You need to be able to receive messages that originate locally (like daily logwatch information, local bounces, etc).

All these emails will be delivered successfully with disabled RELAY as above. Just believe me or test it yourself :-)

> Defining what email for which domain your server accepts (as suggested above) is located in /etc/mail/local-host-names

That's true. All mail, that comes to local-host-name will be accepted regardless of 'RELAY' rules. All 'RELAY' rules are applicable to outgoing email.
0
 
LVL 28

Expert Comment

by:Jan Springer
ID: 24831273
This doesn't address the author's problem.  Vanilla sendmail does not do regular expressions.  He also hasn't given any indication that the mail server does _not_ talk to other MTAs.  And, he hasn't said that other users may/may not send to other domains.

Removing the localhost information does not address this issue.
0
 
LVL 1

Author Comment

by:aloknet21
ID: 24833046
I want to disable to some users only. i have seen on google that make aliases for user who you want to enable send outside domain. and  do not make aliases for users who you want to restrict.

i have tested this but it is not working.

Please suggest i want to restrict only some users not all users?
0
Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

 
LVL 29

Expert Comment

by:fosiul01
ID: 24877161
Have a look to this one

http://www.sendmail.org/~ca/email/restrict.html


Create this file

/etc/mail/intern.only

insert aliases in intern.only like this

alok

then in sendmail.cf file add those rules


#LOCAL_CONFIG
F{Internal}/etc/mail/intern.only
#LOCAL_RULESETS
SLocal_check_rcpt
# get sender address and canonify it
R$*                             $: $1 $| $>3 $&f
R$* $| <>                       $@ OK           <> is always ok
R$* $| $={Internal} <@$=w.>     $: $1           luser@mail.domain.co.uk?
R$* $| $={Internal}             $: $1           luser?
R$* $| $*                       $@ OK           someone else
R$*                             $: $>3 $1       check recipient
R$+<@$=w.>                      $@ OK           local? ok
R$+<@$+>                        $#error $@ 5.1.8 $: "551 sorry luser your boss does not like you"



Now when alok will try to sent email, that email will be saved in user's home directory as deadletter . and in /var/log/maillog
you will see its saying, "sorry alok your boss does not like you"

0
 
LVL 1

Author Comment

by:aloknet21
ID: 24877181
should i add these lines at sendmail.mc file and then use m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

should i define my domain name here also?

R$* $| <>                       $@ OK           <> is always ok
R$* $| $={Internal} <@$=w.>     $: $1           luser@mail.domain.co.uk?

please suggest!
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24877192
no add those rules in sendmail.cf  ( NOT sendmail.mc )


R$* $| $={Internal} <@$=w.>     $: $1           luser@mail.yourmailserver.com?  ( THIS ONE IS MAILSERER HOSTNAME)
R$* $| $={Internal}             $: $1           luser?  


you dont have to insert username here, keep everything as it is. instead of mail.yourmailserver.com , write your mailserver host name thats all
0
 
LVL 1

Author Comment

by:aloknet21
ID: 24877231
ok
Thanks fosiul. i will check this on sunday because i can't do this on working hours.

Thanks for your support.

Alok
0
 
LVL 29

Accepted Solution

by:
fosiul01 earned 500 total points
ID: 24877238
you welcome
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

New-MailboxSearch Powershell Command and step by step approach to Search and Extract Emails form Exchange 2013 Journaling server.
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now