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
668 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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
 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 36
check if a sub domain uses a CNAME or A RECORD? 1 32
CENTOS DHCP Server / PXE/TFTP 14 72
Migrate Databases Exchange server 2013 to 2016 2 18
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
There was an incident about the POP3 issue for the double read receipts and delivery receipts in Exchange 2013.  There was huge research been done and found solution for the duplicate mails. Especially when the user gets  duplicate mails.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

776 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