1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

sendmail and *@*.mydomain.com to one local user

Discussion in 'Web and Network Services' started by antolap, May 8, 2012.

  1. antolap

    antolap New Member

    Messages:
    27
    Likes Received:
    0
    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.
     
  2. varda

    varda New Member

    Messages:
    107
    Likes Received:
    0
    In main .mc file:
    Code:
    FEATURE(virtusertable)
    
    In virtusertable file:
    Code:
    domain.tld  username
    
     
  3. antolap

    antolap New Member

    Messages:
    27
    Likes Received:
    0
    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?
     
  4. usdmatt

    usdmatt Member

    Messages:
    543
    Likes Received:
    1
    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...
    
     
  5. antolap

    antolap New Member

    Messages:
    27
    Likes Received:
    0
    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.
     
  6. usdmatt

    usdmatt Member

    Messages:
    543
    Likes Received:
    1
    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.
     
  7. antolap

    antolap New Member

    Messages:
    27
    Likes Received:
    0
    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
     
  8. usdmatt

    usdmatt Member

    Messages:
    543
    Likes Received:
    1
    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
    
     
  9. antolap

    antolap New Member

    Messages:
    27
    Likes Received:
    0
    Yes, I did.

    Ok. This is the output:

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

    usdmatt Member

    Messages:
    543
    Likes Received:
    1
    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
     
  11. antolap

    antolap New Member

    Messages:
    27
    Likes Received:
    0
    Ok, now it's working fine (I didn't understand what's was wrong).

    Many thanks.