LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 08-25-2014, 12:38 PM   #1
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Rep: Reputation: 0
Configuring my sendmail to only send to certain domains


Hi,

Here’s the Linux config …

Code:
[dalvarado@mymachine ~]$ uname -a
Linux qa.mydomain.com 4.2.8.9.amzn1.x86_64 #1 SMP Wed Apr 2 09:36:59 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
I’m trying to configure our sendmail (8.14.4) system to only send emails to domains ending in “@domain.com” or “@domain2.com”. I’m reading through docs and have stumbled upon this file …

Code:
sudo vim /etc/mail/access
Within the file, i see a bunch of entries like so …

Code:
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
I’m not sure how I should add in the fact that I only want to send emails to these specific domains. How do I indicate that?

Thanks, - Dave
 
Old 08-25-2014, 12:46 PM   #2
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
Relaying is rejected by default. The only messages that will be relayed through your system are by those that you specifically allow.

In your example, a message to ANY domain that originates from localhost will be allowed. But, if you tried to connect from another network to send a message, it would get rejected.

Now, if you wanted mail sent to domain example.com, for example, you could have :
Code:
To:Example.com                          RELAY
So anyone that connects to your machine to send a message to example.com would be allowed. Messages sent to other domains would be rejected.

Now keep in mind, this could open you up to backscatter. What we do to avoid that is we populate all valid e-mail accounts in the access file. So ours looks like:
Code:
To:example.com   REJECT
To:jim@example.com  RELAY
To:Sue@example.com  RELAY
...
etc.

So basically it would reject all mail to example.com except for jim, sue and anyone else I specify.
 
Old 08-25-2014, 01:20 PM   #3
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Original Poster
Rep: Reputation: 0
Hi,

I edited the file /etc/mail/access, and added

Code:
To:mydomain.com                          RELAY
To:mydomain2.com                         RELAY
Then I restarted sendmail using

Code:
sudo /etc/init.d/sendmail restart
However, when I was able to send an email to a "@gmail.com" domain. Is there something else I need to do to restrict the email? I use m4 to build the "sendmail.cf" file, but I didn't do that before restarting. Anything else I need to do?
 
Old 08-25-2014, 01:22 PM   #4
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
You have to re-build your access database. Something like:

Code:
makemap hash /etc/mail/access < /etc/mail/access
 
Old 08-25-2014, 01:38 PM   #5
laredotornado
Member
 
Registered: Apr 2011
Posts: 71

Original Poster
Rep: Reputation: 0
Hi,

So I did this ...

Code:
[dalvarado@mymachine ~]$ sudo makemap hash /etc/mail/access < /etc/mail/access
[sudo] password for dalvarado: 
[dalvarado@mymachine ~]$ sudo /etc/init.d/sendmail restart
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]
but then I was still able to send to the "@gmail.com" email. Here's my complete /etc/mail/access file ...

Code:
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
Connect:email-smtp.us-east-1.amazonaws.com RELAY
Connect:ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com RELAY
To:domain1.com                          RELAY
To:domain2.com                        RELAY
 
Old 08-25-2014, 01:55 PM   #6
YankeePride13
Member
 
Registered: Aug 2012
Distribution: Ubuntu 10.04, CentOS 6.3, Windows 7
Posts: 262

Rep: Reputation: 55
Are you sending to gmail from the machine itself? Cause the connect lines allow you to send anything from the localhost.

EDIT

Also, if you send mail from email-smtp.us-east-1.amazonaws.com and ses-smtp-prod-335357831.us-east-1.elb.amazonaws.com it will also allow you to send anywhere
 
  


Reply



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
How do I limit which domains sendmail can send to? bax Linux - Software 13 10-05-2009 11:13 AM
prevent to send mails to public domains in sendmail mail2mphani Linux - Security 1 03-11-2009 12:37 PM
sendmail - how to send mail from multiple domains? neocontrol Linux - Server 1 05-14-2007 02:18 AM
Configuring sendmail for multiple domains pikky2006 Linux - General 2 07-15-2006 01:30 AM
Sendmail: How can I avoid some users send mail to outside domains? lordphantom82 Linux - Software 0 11-16-2004 07:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:18 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration