LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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

Reply
 
Search this Thread
Old 10-21-2009, 04:59 AM   #1
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Rep: Reputation: 33
How to restrict some uses to send mail to outside domains


How to restrict some uses to send mail to outside domains except local in sendmail.

I am using ( CentOS5 + Sendmail )

Thanks in Advance.
 
Old 10-21-2009, 05:03 AM   #2
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,267

Rep: Reputation: 99
Lightbulb

Quote:
Originally Posted by mail4vijay View Post
How to restrict some uses to send mail to outside domains except local in sendmail.

I am using ( CentOS5 + Sendmail )

Thanks in Advance.
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.
 
Old 10-21-2009, 11:52 PM   #3
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by vikas027 View Post
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 and waiting for further reply.
 
Old 10-22-2009, 08:29 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,267

Rep: Reputation: 99
Quote:
Originally Posted by mail4vijay View Post
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 View Post
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.
 
Old 11-04-2009, 11:45 AM   #5
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by vikas027 View Post
NO, he would not be able to do it as per my example.


Sorry, I do not have much idea about this, there must be an option, lets wait for someone else to answer.
Can someone from the LQ reply on this thread if can.

Any help would be greatly appreicated.
 
Old 11-04-2009, 01:39 PM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,937

Rep: Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330
Hi,

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
 
Old 11-04-2009, 11:40 PM   #7
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by bathory View Post
Hi,

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 again
 
Old 02-16-2010, 11:39 PM   #8
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by mail4vijay View Post
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.
 
Old 02-17-2010, 04:42 AM   #9
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,937

Rep: Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330
Hi,

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
 
Old 02-17-2010, 07:54 PM   #10
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by bathory View Post
Hi,

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.

> rpm -qa |grep -i sendmail
sendmail-cf-8.13.8-2%{dist}
sendmail-8.13.8-2%{dist}
> arch
x86_64
> cat /etc/redhat-release
CentOS release 5.4 (Final)
Attached Files
File Type: txt sendmail.cf.txt (60.0 KB, 33 views)

Last edited by mail4vijay; 02-26-2010 at 03:47 AM.
 
Old 02-18-2010, 12:20 AM   #11
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,937

Rep: Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330
Hi,

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
Attached Files
File Type: txt sendmail.cf.txt (58.6 KB, 50 views)
 
Old 02-18-2010, 01:02 AM   #12
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by bathory View Post
Hi,

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.

Code:
> cat /etc/mail/intern.only
vksingh@example.com
> grep vksingh /etc/passwd
vksingh@example.com:x:599:502::/home/example.com/homes/vksingh:/dev/null
Code:
Feb 18 12:21:16 mailserver sendmail[29793]: alias database /etc/aliases rebuilt by root
Feb 18 12:21:16 mailserver sendmail[29793]: /etc/aliases: 78 aliases, longest 2552 bytes, 3412 bytes total
Feb 18 12:21:16 mailserver sendmail[29798]: starting daemon (8.13.8): SMTP+queueing@01:00:00
Feb 18 12:21:16 mailserver sm-msp-queue[29806]: starting daemon (8.13.8): queueing@01:00:00
Feb 18 12:22:13 mailserver sendmail[29822]: o1I6qBb8029822: from=vksingh@example.com, size=466, class=0, nrcpts=1, msgid=<1266475931.29818@example.com>, relay=root@localhost
Feb 18 12:22:13 mailserver sendmail[29823]: o1I6qDco029823: from=<vksingh@example.com>, size=598, class=0, nrcpts=1, msgid=<1266475931.29818@example.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 18 12:22:13 mailserver sendmail[29822]: o1I6qBb8029822: to=rajmail2@gmail.com, ctladdr=vksingh@example.com (0/0), delay=00:00:02, xdelay=00:00:00, mailer=relay, pri=30466, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (o1I6qDco029823 Message accepted for delivery)
Feb 18 12:22:17 mailserver sendmail[29827]: o1I6qDco029823: to=<rajmail2@gmail.com>, delay=00:00:04, xdelay=00:00:04, mailer=relay, pri=120598, relay=[x.x.x.x] [x.x.x.x], dsn=2.0.0, stat=Sent (OK)

Last edited by mail4vijay; 02-18-2010 at 01:04 AM.
 
Old 02-18-2010, 02:29 AM   #13
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,937

Rep: Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330
Could you test if the rules work by telneting on your server port 25?
Btw
Quote:
> grep vksingh /etc/passwd
vksingh@example.com:x:599:502::/home/example.com/homes/vksingh:/dev/null
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
 
Old 02-18-2010, 03:35 AM   #14
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by bathory View Post
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??

Any ways Thanks a lot once again.
 
Old 02-18-2010, 03:48 AM   #15
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,937

Rep: Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330Reputation: 1330
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:
Code:
vksingh@example.com vksing
vksingh@example.net vksingg
Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict user to send mail jeesun Linux - Server 12 10-14-2009 04:40 AM
how to restrict a user to send mails only to 3 email IDs in postfix mail server sharath41 Linux - Server 1 07-04-2008 03:40 PM
sendmail - how to send mail from multiple domains? neocontrol Linux - Server 1 05-14-2007 02:18 AM
Outlook can not send mail to external domains fhejazi General 7 09-08-2006 02:48 PM
Sendmail: How can I avoid some users send mail to outside domains? lordphantom82 Linux - Software 0 11-16-2004 07:23 PM


All times are GMT -5. The time now is 07:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration