LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Sendmail: send-only when local system has no domain name? (http://www.linuxquestions.org/questions/linux-software-2/sendmail-send-only-when-local-system-has-no-domain-name-763246/)

catkin 10-20-2009 12:49 PM

Sendmail: send-only when local system has no domain name?
 
Hello :)

Is it possible to configure sendmail to meet these requirements? The intention is that any locally generated mail will appear identifiably in my day-to-day inbox.

Requirements
  1. /etc/hosts to be
    Code:

    127.0.0.1 localhost localhost.localdomain
    192.168.1.47 CW8 CW8.localdomain

    Note: I believe these values are "good practice" and will integrate well with most packages.
  2. All mail sent to local users to be forwarded to <local recipient user name>.CW8@<my domain name> with a "From" address of <local sender user name>@<my domain name>. Note: the "To" address will route mail to my day-to-day inbox. The "From" address meets my mail service provider's requirement that "From" addresses include a valid internet domain name.

Attempt so far

After several attempts this is the closest.
  • Added lines to sendmail .mc file (and processed into /etc/mail/sendmail.cf using m4):
    FEATURE(delay_checks)dnl
    FEATURE(masquerade_envelope)dnl
    FEATURE(allmasquerade)dnl
    FEATURE(masquerade_entire_domain)dnl
    MASQUERADE_AS(`<my domain name>')dnl
  • Added aliases to /etc/mail/aliases (and processed into aliases.db usng newlaiases; this produced a warning about a duplicate entry for root)
    root:root.CW8@<my domain name>
    root@CW8.localdomain:root.CW8@<my domain name>

Result
    • As user c, ran
      Code:

      echo "hello" | mail -s test root
    • Mail was received (in Outlook) displayed as from Charles (taken from /etc/passwd file?) and to root@CW8.localdomain. The headers were
      Code:

      Return-Path: <c@<my domain name>>
      Received: from CW8.localdomain ([<my external IP address>])
              (authenticated bits=0)
              by rs49.luxsci.com (8.13.1/8.13.7) with ESMTP id n9KGvC6P020547
              (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
              for <root.CW8@<my domain name>>; Tue, 20 Oct 2009 11:57:14 -0500
      Received: from CW8.localdomain (localhost [127.0.0.1])
              by CW8.localdomain (8.14.3/8.14.3) with ESMTP id n9KGvC1k027490
              for <root@CW8.localdomain>; Tue, 20 Oct 2009 22:27:12 +0530
      Received: (from c@localhost)
              by CW8.localdomain (8.14.3/8.14.3/Submit) id n9KGvBvV027489
              for root; Tue, 20 Oct 2009 22:27:11 +0530
      From: Charles <c@<my domain name>>
      Message-Id: <200910201657.n9KGvBvV027489@CW8.localdomain>
      Date: Tue, 20 Oct 2009 22:27:11 +0530
      To: root@CW8.localdomain

    • As root, ran
      Code:

      echo "hello" | mail -s test root
    • Returned mail notification was received (in Outlook) with
      Code:

      root.CW8@<my domain name>
          (reason: 553 5.1.8 <root@CW8.localdomain>... Domain of sender address root@CW8.localdomain does not exist)
          (expanded from: <root@CW8.localdomain>)

The showstopper is that sendmail is not changing root@CW8.localdomain to root@<my domain name>. Other deviations from the requirements would be nice-to-fix but that's the biggy

irishbitte 10-21-2009 07:15 AM

Why not just change your /etc/hosts file to read
Code:

192.168.1.47 CW8.<yourdomain>
instead of
Code:

192.168.1.47 CW8.localdomain
As I understand it, this version is actually what you refer to as 'best practice'? I'm open to my interpretation being wrong though!

Essentially, the real problem you will hit with any of this is an inability to reply to any mails from this box, unless it is listed locally or globally as an MX record in DNS.

catkin 10-21-2009 02:27 PM

Quote:

Originally Posted by irishbitte (Post 3727172)
Why not just change your /etc/hosts file to read
Code:

192.168.1.47 CW8.<yourdomain>
instead of
Code:

192.168.1.47 CW8.localdomain
As I understand it, this version is actually what you refer to as 'best practice'? I'm open to my interpretation being wrong though!

Thanks irishbitte :)

Yes, it's the standard solution and I'm increasingly wondering why I don't just go for it! Perhaps my reluctance is more emotional than logical, something along the lines of keeping things "clean"; it's a good heuristic in programming or database work; never use a variable or field for something different because it happens to be available; "say what you mean and mean what you say'. Following this line of half-thought-through reasoning, CW8 has nothing to do with <my domain>; it is only my mail service provider's (reasonable) requirement that all mails are from a valid domain that requires this fudge; it is cleaner to limit the fudge to where it is actually necessary, that is sendmail and sendmail is immensely configurable -- that's why its config file is so complex we need m4 to write it!

Quote:

Originally Posted by irishbitte (Post 3727172)
Essentially, the real problem you will hit with any of this is an inability to reply to any mails from this box, unless it is listed locally or globally as an MX record in DNS.

Understood and no problem -- CW8 is not a mail server, it is a personal workstation that may report errors by email (smartd is configured, EDAC is on the way). Sure I could just check the local mails every now and then but what if I was away from home for a while? And it's a model for supporting other Linux systems.

irishbitte 10-21-2009 02:55 PM

Yup, you're on the right track now, and for error reporting your setup is perfect. I personally never knew that 'localdomain' was a variable to store local domain name! Is this coming from a netgroups setup by any chance? I've never used netgroups, but it sounds like one of the convenient things it provides....

catkin 10-22-2009 05:29 AM

Quote:

Originally Posted by irishbitte (Post 3727629)
Yup, you're on the right track now, and for error reporting your setup is perfect. I personally never knew that 'localdomain' was a variable to store local domain name! Is this coming from a netgroups setup by any chance? I've never used netgroups, but it sounds like one of the convenient things it provides....

No, not netgroups, just plain files. I figure I'm "boldly going" on this one so I'll do as you suggested and add exploring obscure corners of sendmail configuration to my TODO list.


All times are GMT -5. The time now is 07:45 PM.