Sunday, 4 August 2013

Centos 6/RHEL install & run Mailx

E-mail capability for the root user is not activated by default and you may find it useful to ensure that this service is enabled and able to send messages.

You may be required to generate e-mail reports that should be issued to, or generated on the behalf of the root user, while those of you who enjoy the benefit of e-mail in order to issue notices will want a convenient solution that may not require a comprehensive mail server. E-mail capability is essential to every aspect of the administrator's role and this post looks at activating the root's e-mail and enabling all messages to be sent to a destination of your choice.

We install and set up mailx, a sending and recieving facility for mail on a Linux system.


First download mailx with yum

$ sudo yum -y install mailx

Open up the aliases file to add an address

$ sudo vi /etc/aliases

Scroll down to the person who gets roots email

# root:       marc

Uncomment the line and change the value to your choice

root     example@yourdomain.com

You can also send it to existing users as below

root:      username1, username2

Save and close the file, then run the following to implement changes.

newaliases

Now send a test Email to check it works properly.

# echo "Test Email" | mail -s "This is a test email." externalemail@domain.com

You can check if anything is in the mailbox with

$ mailq
Mail queue is empty






And not forgetting the manual pages


$ man mailx

Quick and easy set up of the Mailx program.



2 comments: