[SOLVED] How to restrict some uses to send mail to outside domains
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You need to modify this file for this --> /etc/mail/access
See these examples.
Code:
Connect:mail.yahoo.com REJECT # Allow yahoo.com domain
To:a1@server.vikas.com REJECT # Reject a1 user from recieving mails
From:b1@server.vikas.com REJECT # Reject b1 user from sending mails
A restart of sendmail is required after making changes.
Thanks Vikas for Reply , if i reject b1 user in access file , is it possible for him to send mail in local domain?. My main idea how to stop some users to send e-mail outside the local domain ( like yahoo / gmail etc) , but all should allow sending / receiving inside the local domain.
Thanks Vikas for Reply , if i reject b1 user in access file , is it possible for him to send mail in local domain?.
NO, he would not be able to do it as per my example.
Quote:
Originally Posted by mail4vijay
My main idea how to stop some users to send e-mail outside the local domain ( like yahoo / gmail etc) , but all should allow sending / receiving inside the local domain.
Sorry, I do not have much idea about this, there must be an option, lets wait for someone else to answer.
Last edited by vikas027; 10-22-2009 at 08:42 AM.
Reason: added few more words.
What you want to achieve is done using custom rulesets. Take a look at this for details.
Having tested this on my sendmail 8.14.3, I had to change just SLocal_check_rcpt to Scheck_rcpt (besides that according to the post, this has to be done with sendmail prior 8.9) and replace the rules in the original sendmail.cf (you have to make a backup before editing sendmail.cf).
What you want to achieve is done using custom rulesets. Take a look at this for details.
Having tested this on my sendmail 8.14.3, I had to change just SLocal_check_rcpt to Scheck_rcpt (besides that according to the post, this has to be done with sendmail prior 8.9) and replace the rules in the original sendmail.cf (you have to make a backup before editing sendmail.cf).
Regards
Thanks for reply , i will try this in my sendmail.cf and let you know if i get any issue.
Thanks for reply , i will try this in my sendmail.cf and let you know if i get any issue.
Thanks again
Hi,
After a long time i got chance to test this settings per given link but it is not working for me , even i created intern.only file , but still my local users define in intern.only file are able to send mail to gmail / hot mail etc.
I am using sendmail-cf-8.13.8-2%{dist}/sendmail-8.13.8-2%{dist}
in CentOS 5.4 64 bits.
Quote:
F{Internal}/etc/mail/intern.only
###SLocal_check_rcpt
Scheck_rcpt
# get sender address and canonify it
R$* $: $1 $| $>3 $&f
R$* $| <> $@ OK <> is always ok
R$* $| $={Internal} <@$=w.> $: $1 luser@local.host?
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"
#R$* $: $1 $| $>"Local_check_rcpt" $1
#R$* $| $#$* $#$2
#R$* $| $* $@ $>"Basic_check_rcpt" $1
I did both $check_rcpt and $Local_check_rcpt settings one by one, but did not get succeeded.
Any help / suggestions would be greatly appreciated.
Have you created the /etc/mail/intern.only file? That should contain the usernames of the local users you want to restrict.
Note also that you should use <Tab> between the LHS and RHS entries for the rules (not spaces)
Have you created the /etc/mail/intern.only file? That should contain the usernames of the local users you want to restrict.
Note also that you should use <Tab> between the LHS and RHS entries for the rules (not spaces)
Regards
Thanks for reply Bathory once again, Yes i created /etc/mail/intern.only file properly with tested only one user.
Code:
cat /etc/mail/intern.only
vksingh@example.com
I used tab between LHS RHS entries , i think something i missed out??
I am enclosing herewith my sendmail.cf file. Could you please have a look and suggest me what changes i should make here per my file.
I am using centos 5.4 64 bits + sendmail + smarthosting.
I've added the changes needed in the attached sendmail.cf. Make a backup of your current sendmail.cf and then restart sendmail using this one.
Cheers
I am using squirrelmail for sending email and Still i am able to send mail outside the domain for that user which is in intern.only ? I am using virtualmin for sendmail Is that causing issue.
Could you test if the rules work by telneting on your server port 25?
Btw
doesn't look like a valid username.
You can change it to vksingh in /etc/passwd and maybe use this also in /etc/mail/intern.only
Thanks so Much Bathory , this time i did only used 'vksingh' only instead of vksingh@example.com in /etc/mail/intern.only and now it starts working for me.
Code:
cat /etc/mail/intern.only
vksingh
I am using vksingh@example.com in /etc/passwd as i am using virtmin with 2 domains and in user naming convention i choose username@domain i.e. it is having all user name in example.com with <user-name>@example.com.
But when i use vksingh@example.com it sends message to gmail without fail? Can't use username@domain name convetion??
Glad to see it worked
But please note that vksingh@example.com is not a valid useranme for /etc/passwd. If you want to use the same username with different domains, you go with /etc/mail/virtusertable:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.