LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices



Reply
 
Search this Thread
Old 10-30-2012, 12:21 PM   #1
stoat
Member
 
Registered: May 2007
Distribution: LFS
Posts: 493

Rep: Reputation: 133Reputation: 133
Set up local email in a BLFS system


What I Mean

What I mean is for one user to be able to send a message to another user or to root or vice versa all within the local system.

mail_notice.jpgmail_open.jpg

I don't really need to do that though. What I need is for certain applications that can email warnings to be able to send those messages to me on the local machine. That also can be handy for scripts that need to notify somebody that something happened. For example, a test message from the Smartmontools smartd daemon to root (aliased to a non-root user)...

mail_test.jpg

For people who already have a mail MTA and MUA installed, this will not be interesting because they can already do this. I didn't. And I promise you that the information about this on the Internet is not easy to piece together. I looked through stuff for a long time until I found something helpful and learned how to do this. Most information out there is about sending to and receiving from remote machines. I only want to work with this within a system.

Anyway, all you have to do is install two simple packages that happen to be in the current BLFS book. One is an MTA (mail transport agent) and the other is an MUA (mail user agent). I tried several different ones and finally ended up with Mailx for the MUA and Postfix for the MTA. That part was easy, but it didn't work at first. Then it worked for a minute and went away, but I didn't know what I did to make it work or stop working. Finally, I got it all figured out and can reproduce the whole thing reliably. It's mostly about getting the configuration files right. Mostly.



Installing Postfix and Mailx

1. Install Postfix. The current version is postfix-2.9.4 and can be found in chapter 21. I merely did the basic steps in the book for installing Postfix with OpenSSL. No problems.

2. Create /etc/aliases. This is one of the steps in "Configuration Information" in the book for Postfix. Again, I did the cat command in the book and changed <LOGIN> to my regular non-root user.

3. Edit /etc/postfix/main.cf. This is more from the configuration of Postfix, but the book is stingy with details for this part. Open the default main.cf file created by Postfix and uncomment or change the following items. My hostname is the venerable localhost.localdomain. Change that as needed for yours in the following...
myhostname = localhost
mydomain = localdomain
myorigin = $myhostname
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks_style = host


And add this at the end if you want to keep things local...

# The following setting disables the delivery of non-local mail.
default_transport = error:outside mail is not deliverable
4. Finish and test the configuration. The following commands will run without returning any messages if everything is okay so far.
postfix upgrade-configuration
postfix check
5. Rebuild the data base for the mail aliases file.
newaliases
6. Install the postfix init script as described in the book. This will start the Postfix mail daemon automatically at boot time.

7. Reboot or run the init script to start the postfix daemon.
/etc/rc.d/init.d/postfix start
8. Install Mailx. The current version in the book is mailx-12.4 and can be found in chapter 19. I installed Mailx exactly as described in the book with the patch for OpenSSL. I did nothing to its default configuration file /etc/nail.rc.



Using Mailx

There is plenty of documentation available for learning to use Mailx. Here are some very basic things. The commands mail and nail both are symlinks to the executable mailx.

mail

Check your mail messages...
Code:
$ mail
Heirloom mailx version 12.4 7/29/08.  Type ? for help.
"/var/mail/boo": 3 messages
>O  1 Jean Finch         Mon Oct 29 21:05   20/641   WARNING!
 O  2 Jean Finch         Mon Oct 29 21:08   20/646   False Alarm!
 O  3 Arthur Radley      Mon Oct 29 21:49   25/878   Re: False Alarm!
?
mail address

Send mail to address.
Code:
$ mail boo
Subject: This is an important message
How am I doing?
.
EOT
The ? prompt

When the mail command lists the mail in the user's mailbox, it ends by printing a ? prompt for commands. Here are some things to do at the ? prompt.
d, delete [msglist]
Code:
d	Delete the current message.
d3	Delete the third message.
d1-3	Delete messages 1 to 3.
r, reply

Reply to the sender and all other recipients of the original message.

R, Reply

Reply only to the sender, not other recipients.

h, headers
Code:
h	Show the list of message headers (or the first 18 in a long list).
h+	Show the next 18 headers in a long list.
h-	Show the previous 18 headers in a long list.
?, help

Print a brief summary of commands.

q, quit

Terminate the session saving all undeleted and unsaved messages.

x, ex, exit

Return immediately to the shell without modifying the user's system mailbox.
Send messages via the command line or from a script. Example...
Code:
echo "Something really important happened." >> message_file.txt
echo "Somebody should do something about this." >> message_file.txt
mail -s "Some interesting stuff" scout@localhost.localdomain < message_file.txt
See the many Mailx references and tutorials out there for much more Mailx information.



References:

http://forums.gentoo.org/viewtopic.php?t=61606
http://www.gentoo-wiki.info/TIP_Post...ocal_Mail_Only
http://cafim.sssup.it/~giulio/other/...Mail_Only.html
http://linux.die.net/man/1/mailx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How would i configure/set up postfix to send email from my local pc ? cola Linux - Server 17 11-06-2011 07:44 AM
Doubleprompt in LFS-6.3 system after starting BLFS....?? andrew.sharp3 Linux - Software 0 01-15-2008 09:29 PM
Trying to set system's clock to local time; where is tzconfig gone? odiseo77 Debian 5 11-18-2007 10:45 PM
Should I set system clock to GMT or local time? square_eyes Linux - General 4 01-22-2007 04:59 PM
Cannot ping local system when pinging system is set for static IP SkipHuffman Linux - Networking 4 08-22-2005 12:56 PM


All times are GMT -5. The time now is 01:10 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration