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.
 
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?
 
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...
 
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.
 
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.
 
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
 
usdmatt said:
You did run the following

Code:
make install restart

Yes, I did.

usdmatt said:
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
 
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
 
Back
Top