LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-20-2009, 12:49 PM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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

Last edited by catkin; 10-20-2009 at 01:17 PM. Reason: Tidying
 
Old 10-21-2009, 07:15 AM   #2
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213
Blog Entries: 1

Rep: Reputation: 88
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.
 
Old 10-21-2009, 02:27 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by irishbitte View Post
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 View Post
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.
 
Old 10-21-2009, 02:55 PM   #4
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213
Blog Entries: 1

Rep: Reputation: 88
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....
 
Old 10-22-2009, 05:29 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by irishbitte View Post
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.
 
  


Reply

Tags
localhost, masquerade, sendmail



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Postfix/Sendmail] refuses to send to domain Liquidity Linux - Server 15 04-23-2011 05:30 AM
Postfix cant send mail in local or any outer domain vikki Linux - Server 4 07-22-2009 03:40 PM
local postfix server not able to send mails to other domain subramanyabs1984 Linux - Server 1 03-13-2009 05:27 AM
Sendmail trying to send to local accounts instead of external ejellard Linux - Server 3 03-24-2008 02:40 PM
how to refuse to send email to some domain with sendmail? lzyking Linux - Software 3 09-16-2003 08:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration