LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-12-2008, 03:36 PM   #1
gonzo22
LQ Newbie
 
Registered: Jan 2005
Posts: 5

Rep: Reputation: 0
emails from root@server.com


Hello all,

I need help with the following. I have a script in my /root/.bash_profile that alerts (sends email) to my company email account if someone logs in to the server. Here is the script:

echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" user@company.com

I get the email and all works fine with the script - one problem though. Email that I receive is forwarded from root@server.com. Here is my question, how do I change this? I would like to change root@server.com to something that looks like mgmt.alerts@server.com

All suggestions always appreciated.

Thanks!!

K,
 
Old 01-12-2008, 05:12 PM   #2
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
A few ways to change the from:

1) Create a file within root's home directory called ".forward" and enter the email address. The system should then use this instead of the default.

or

2) Edit /etc/alias to point root at the email address of your choice.

or

3) Add the -r switch to your command line i.e.

Code:
echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" -r"mgmt.alerts@server.com" user@company.com
 
  


Reply



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 can I set up an email server and route emails from there to another server adeydas8 Linux - Networking 2 05-16-2006 08:05 AM
Receiving Emails as a server deleted_user_01 Linux - Newbie 14 02-17-2005 09:15 AM
SMART tools and root emails albean Linux - Newbie 0 12-30-2004 11:45 AM
not receiving emails from server eliboone Red Hat 9 08-29-2003 11:47 AM
How can iI get emails from outside mail server? bamboo Linux - Networking 3 11-07-2002 06:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:39 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