Monday, July 5, 2010

Forward root email to external email

Extracted from: http://dettox.blogspot.com/2008/01/automatic-forward-to-another-email.html

Root account
editing the file /etc/aliases we can add an email alias for every account on the server

...
ftp-adm: ftp
ftp-admin: ftp
www: webmaster
webmaster: root
noc: root
security: root
hostmaster: root
info: postmaster
marketing: postmaster
sales: postmaster
support: postmaster
# Person who should get root's mail
root: root
...

so in this case we can write:

...
root: root, example@domain.com
...

running the command newaliases the change will take effect:

[root@localhost ~]# newaliases
/etc/aliases: 77 aliases, longest 22 bytes, 791 bytes total
[root@localhost ~]#

every mail to root@localhost will be forwarded to example@domain.com leaving a copy on the server.

User account

to forward user address without root privileges, just create the file .forward in the home directory with inside the name of the mail address:

[dettox@localhost ~]$ pwd
/home/dettox
[dettox@localhost ~]$ echo "example@domain.com" > .forward
[dettox@localhost ~]$ chmod 644 .forward
[dettox@localhost ~]$

every mail to dettox@localhost will be forwarded to example@domain.com without leaving a copy on the server.

No comments:

Post a Comment