Sunday, January 16, 2011

FreeBSD's sendmail

-bash-3.2# hostname 
name.foo.bar.domain.tld
-bash-3.2# 

whenever I send an email it leaves as userid@name.foo.bar.domain.tld, I need to have sendmail change it to userid@domain.tld

how do I do that?

  • # my official domain name
    # ... define this only if sendmail cannot automatically determine your domain
    #Dj$w.Foo.COM
    

    should be in /etc/mail/sendmail.cf

    alexus : so I should have Dj$w.domain.tld ?
    petre : yes, something like that
    alexus : i tried in both sendmail.cf and submit.cf, not working for me...
    petre : did you restart sendmail after modifying .cf ?
    alexus : of course /etc/rc.d/sendmail restart
    From petre
  • Assuming you are using the default installed FreeBSD sendmail you should not be editing the .cf files directly. They are generated from .mc files in the /etc/mail directory.

    There is a Makefile in /etc/mail that will generate the .cf from the .mc files

    Add the following line to the .mc files to set the default domain:

    define(`confDOMAIN_NAME',`domain.tld')
    

    If you really want to edit the .cf file directly, I believe the correct line is:

    Djdomain.tld
    

    (don't include the $w.)

    Update: How to use make to regenerate your .cf

    cd /etc/mail
    make #the first time you do this it will copy freebsd.mc and freebsd.submit.mc to ${HOSTNAME}.mc and ${HOSTNAME}.submit.mc then generate the .cf files
    make install   # will copy ${HOSTNAME}.cf and ${HOSTNAME}.submit.cf to sendmail.cf and sendmail.submit.cf
    make restart  # will restart your sendmail processes
    

    you must be root.

    alexus : after I make change to freebsd.mc what do I need to to in order to convert that .mc to .cf?
    alexus : make -C /etc/mail ?
    Craig : updated the answers with make usage
    alexus : that worked, thank you very much although just FYI for others you need to make a change to ${HOSTNAME}submit.mc not ${HOSTNAME}.mc
    From Craig

0 comments:

Post a Comment