14de4 [Solved] sendmail and *@*.mydomain.com to one local user - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Web & Network Services

Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old May 8th, 2012, 14:18
antolap antolap is offline
Junior Member
 
Join Date: Mar 2012
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default sendmail and *@*.mydomain.com to one local user

Hi,

I would like to know if it's possibile to configure the default sendmail in FreeBSD 9 to catch all emails and put then in a local user mail folder. Is it possibile to use the default sendmail or should I change it?

I did this, in Debian with exim4, so DNS is ok for that to work. Which file should I modify?

I read the handbook, but I haven't understood if it's possibile or not.

Thanks.

Last edited by DutchDaemon; May 8th, 2012 at 22:50. Reason: Mind your writing style: http://forums.freebsd.org/showthread.php?t=18043 / use a spell-checker
Reply With Quote
  #2  
Old May 8th, 2012, 20:31
varda varda is offline
Junior Member
 
Join Date: Mar 2009
Posts: 95
Thanks: 1
Thanked 19 Times in 19 Posts
Default

In main .mc file:
Code:
FEATURE(virtusertable)
In virtusertable file:
Code:
domain.tld  username

Last edited by DutchDaemon; May 8th, 2012 at 22:50.
Reply With Quote
  #3  
Old May 10th, 2012, 08:53
antolap antolap is offline
Junior Member
 
Join Date: Mar 2012
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It doesn't work. If I send an email to test@mydomain in /var/log/maillog I read:
Code:
relaying denied
Do I have to set also other files?

Last edited by DutchDaemon; May 10th, 2012 at 22:30. Reason: Formatting & Style: http://forums.freebsd.org/showthread.php?t=8816 / http://forums.freebsd.org/showthread.php?t=18043
Reply With Quote
  #4  
Old May 10th, 2012, 14:22
usdmatt usdmatt is offline
Member
 
Join Date: Mar 2009
Posts: 253
Thanks: 1
Thanked 67 Times in 56 Posts
Default

I've never found a need to edit the .mc file to support virtusertable, it's in there by default.

The steps I usually do are as follows:

Add the domain to /etc/mail/local-host-names (one domain per line) to tell sendmail it handles mail for the domain. - This is probably why you get relaying denied.

Add the following to /etc/mail/virtusertable
I always put the @ at the start but it may not be required

Code:
@domain.tld    user
Then run the following inside /etc/mail to rebuild & reload.

Code:
make install restart
I would say, however, having a catch-all is rarely a good idea. We see numerous dictionary based spam attacks against domains we host which would end up in massive amounts of email in the catch-all box if we enabled them. As long as you have entries in virtusertable for each email address you do want to use, I see little point in accepting anything else.

I usually do the following:

Code:
@domain.tld       error:nouser User unknown
sales@domain.tld  user1
info@domain.tld   user1
me@domain.tld     user1
you@domain.tld    user2
etc...

Last edited by usdmatt; May 10th, 2012 at 14:25. Reason: clarify local-host-names format and add virtusertable example
Reply With Quote
  #5  
Old May 10th, 2012, 16:12
antolap antolap is offline
Junior Member
 
Join Date: Mar 2012
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It doesn't work. If I send an email to user@mydomain I get in maillog:
Code:
User unkown
I would like to redirect all mails (directed to anyone) to one local user.

Last edited by DutchDaemon; May 10th, 2012 at 22:30. Reason: Formatting & Style: http://forums.freebsd.org/showthread.php?t=8816 / http://forums.freebsd.org/showthread.php?t=18043
Reply With Quote
  #6  
Old May 10th, 2012, 16:27
usdmatt usdmatt is offline
Member
 
Join Date: Mar 2009
Posts: 253
Thanks: 1
Thanked 67 Times in 56 Posts
Default

What exactly do you have in your virtusertable at the moment?

If you want everything to go to one user, you should just have what I put in the first example (the first code block in my last post).

The second example (containing the error:nouser line) is just an example of what I usually do, which is to block the catch-all and set up specific addresses, because I think having a catch-all is a stupid idea (to put it bluntly). I thought maybe you weren't aware that you can set up multiple virtusertable entries for all the addresses you actually want to use.
Reply With Quote
  #7  
Old May 10th, 2012, 19:34
antolap antolap is offline
Junior Member
 
Join Date: Mar 2012
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In virtusertable:

Code:
@mydomain.com    tony

In local-host-names:

Code:
mydomain.com
With this configuration I can't catch all. I understand it could be a problem with the spam, but I want to catch all. Wwhat should I modify to have sendmai accept all mails?

For example mails to:etc.?

thanks

Last edited by DutchDaemon; May 10th, 2012 at 22:33. Reason: READ THE RULES -> http://forums.freebsd.org/showthread.php?t=11799
Reply With Quote
  #8  
Old May 11th, 2012, 10:24
usdmatt usdmatt is offline
Member
 
Join Date: Mar 2009
Posts: 253
Thanks: 1
Thanked 67 Times in 56 Posts
Default

What you have in your virtusertable and local-host-names should be enough to have the catch-all working.

You did run the following in the /etc/mail directory to rebuild the database files and restart sendmail?

Code:
make install restart
Can you post the output of the following command so I can see what sendmail thinks it should be doing with emails to your domain.

Code:
sendmail -bv testuser@mydomain.com
Reply With Quote
  #9  
Old May 11th, 2012, 11:47
antolap antolap is offline
Junior Member
 
Join Date: Mar 2012
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by usdmatt View Post
You did run the following

Code:
make install restart
Yes, I did.

Quote:
Originally Posted by usdmatt View Post
Can you post the output of the following command so I can see what sendmail thinks it should be doing with emails to your domain.

Code:
sendmail -bv testuser@mydomain.com
Ok. This is the output:

Code:
testuser@mydomain.com... User unknown

Last edited by DutchDaemon; May 11th, 2012 at 17:44. Reason: Proper capitalization: http://en.wikipedia.org/wiki/Capitalization
Reply With Quote
  #10  
Old May 11th, 2012, 15:08
usdmatt usdmatt is offline
Member
 
Join Date: Mar 2009
Posts: 253
Thanks: 1
Thanked 67 Times in 56 Posts
Default

I'm not really sure what you can be doing wrong here. I've just tried this on a FreeBSD 9 backup machine I have that has never been configured for email previously:

Code:
backup# sendmail -bv info@mydomain.com
info@mydomain.com... deliverable: mailer esmtp, host mydomain.com., user info@mydomain.com
backup# echo '@mydomain.com matt' >virtusertable
backup# echo 'mydomain.com' >local-host-names
backup# cat virtusertable
@mydomain.com matt
backup# cat local-host-names
mydomain.com
backup# make
/usr/sbin/makemap hash virtusertable.db < virtusertable
chmod 0640 virtusertable.db
backup# sendmail -bv info@mydomain.com
info@mydomain.com... deliverable: mailer local, user matt
This shows that to start off with, Sendmail thinks emails to mydomain.com should be delivered externally via esmtp. After adding to the two files mentioned and rebuilding databases, sendmail thinks it's should be delivered to my local user.

The only thing I can think is either
  1. You have changed some other Sendmail configuration file from standard which has affected the way it works
  2. The username you have put after the space/tab in virtusertable is not a valid local user
Reply With Quote
  #11  
Old May 11th, 2012, 16:44
antolap antolap is offline
Junior Member
 
Join Date: Mar 2012
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok, now it's working fine (I didn't understand what's was wrong).

Many thanks.

Last edited by DutchDaemon; May 11th, 2012 at 17:45. Reason: Capitalization, punctuation.
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh as a local user {Linux} shuxuef Off-Topic 7 March 14th, 2012 19:43
cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MT sjap Web & Network Services 20 January 21st, 2012 15:16
sendmail/postfix local mail delivery problem sand_man Web & Network Services 5 December 24th, 2010 01:52
Using sendmail or sendmail from the ports? HL1234 Installation and Maintenance of FreeBSD Ports or Packages 3 December 17th, 2010 20:37
Syncing emails from user to user albsallu Web & Network Services 27 August 12th, 2009 22:33


All times are GMT +1. The time now is 15:58.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0