Thursday, January 17, 2008

Linux - Automatic Forward to another Email address

I need to forward email received on my linux server to my real daily address.
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.

5 comments:

Anonymous said...

Thanks for the tip, it works for me. :)

Anonymous said...

Hi,
I have read your post here. I'm newbie here at Linux. I can't understand on how to edit this ".forward". Can you post step by step process on how to forward e-mail messages to another e-mail account. I have already an e-mail account on our Linux Mail Server but i can't configure how it is done.

Advanced Thanks Here!!!

dettox said...

as user you have only to create the .forward file in your home dir and add the email address to forward as described in the post.
the Mail Server must be configured to forward mails.

marry said...

Blogs are so informative where we get lots of information on any topic. Nice job keep it up!!
_____________________________

Technology Dissertation

Dissertation Writing service said...

This kind of information is very limited on internet. Nice to find the post related to my searching criteria. Your updated and informative post will be appreciated by blog loving people.

Online Degree's Dissertation

Post a Comment