mail forward root

remove message ssh new mail

comment out the following line in /etc/pam.d/sshd to get rid of it.
session    optional     pam_mail.so standard noenv # [1]

 

mailforward root

http://serverfault.com/questions/243669/procedure-to-forward-root-email-to-external-email

echo "root: you@yourmail.com" >> /etc/aliases && newaliases

 

echo "
root:   emailtoforward2@domain.com" >> /etc/aliases

newaliases
/etc/init.d/postfix reload

echo "$HOSTNAME Email Ready" | mail -s 'Email test' root

tail /var/log/mail.log

 

http://blog.bobbyallen.me/2013/02/03/how-to-redirect-local-root-mail-to-an-external-email-address-on-linux/

How to redirect local root mail to an external email address on Linux

 

I run a home file, media and backup server at home on Ubuntu Server 12.04 LTS. I have various cron jobs set-up for various task such as backing up external MySQL databases, web site data and other tasks.

By default, when a cron job runs and if the script or program that runs produces any output (text on the screen) this will email the cron user, in my case, I have setup cron jobs under the root user, therefore emails get sent to root@hostname, so everytime I login via. SSH (which is very rare) I get told about X amount of unread email in /var/mail/root. Now obviously for cron jobs that do create output but you don’t care you can append the cron job line to redirect the output (by appending ‘> /dev/null‘) like so:-
0 * * * * python /etc/example.py > /dev/null

However sometimes you want to know if particular tasks have run successfully and to only have to check a single (external) mail account is much more reasonable, so I’m going to show you how to create a mail alias so emails get sent directly to your external email account.

First of all you need to make sure that you have a mail server installed on your server, I have a default install of Postfix installed, I’ve not done any special configuration to it at all, it will simple be used to end emails externally. – My home server is not set-up to receive any external emails etc.

Lets add your email address as an alias…

So with you favioure text editor, lets edit the /etc/aliases file and add your username and external email address like so:-
root: yourexternalemailaddress@gmail.com

Now run this command:-
newaliases

Now restart Postfix:-
service postfix restart

and to test, run the following command:-
echo test | mail -s "test message" root

You should now be able to check your external email account, in this example I’ve used a gmail account! – Login to your external email account and you should then see your email (if its not in your inbox, check your SPAM folder!)

 

http://unix.stackexchange.com/questions/26666/can-i-change-roots-email-address-or-forward-it-to-an-external-address
Simply create /root/.forward and place your email address in this file. It will be forwarded to your external mail address.
in .forward myaddress@example.com, root@thisserver.com

No Comments

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *