Operating System - HP-UX
1835646 Members
2962 Online
110081 Solutions
New Discussion

How can I forward all local mail?

 
Pedro Cirne
Esteemed Contributor

How can I forward all local mail?

How can I forward all local mail to a single e-mail adress?
10 REPLIES 10
Steven E. Protter
Exalted Contributor

Re: How can I forward all local mail?

all users could have in their home directory a .forward file with that email address.

You could handle it with entries for each user in /etc/mail/aliases

username target@mail.net

For the second suggestion you might want to use a mail macro script: http://www.hpux.ws/buildmail.hpux.text

It will build you a new sendmail.cf file.

After suggestion 2:

/sbin/init.d/sendmail stop
/sbin/init.d/sendmail start

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
john kingsley
Honored Contributor

Re: How can I forward all local mail?

Edit the file /etc/mail/sendmail.cf
Set the variable DH to be the server you want to handle local mail.
DHyour_mail_server.domain.com

Certain users can be excluded by modifying CL.

To foward all local mail to a single e-mail address, I think you will need to setup your alias file to point all accounts to a single alias.
Rick Garland
Honored Contributor

Re: How can I forward all local mail?

The DH value is the one you want to modify.
All local mail will be directed to the specified value
Pedro Cirne
Esteemed Contributor

Re: How can I forward all local mail?

The problem is that on the mail server, the unix login don't exist, so I want to send all local mails to a specific user on a specific server.

Thks
john kingsley
Honored Contributor

Re: How can I forward all local mail?

In this case, you'll want to edit the /etc/mail/aliases. The for every user on your local machine add "single e-mail address":

user1 : user@email-server.domain.com
user2 : user@email-server.domain.com
.
.
.
etc....

Then you'll need to rebuild the alias db by running: /usr/sbin/newaliases

Jeff_Traigle
Honored Contributor

Re: How can I forward all local mail?

John's reference to the aliases file is the one you want in that case. Check out aliases(5) and newaliases(1M) man pages. The downside to the .forward method that was mentioned earlier is that the users could delete the file, thus breaking the forwarding policy you're trying to enforce.
--
Jeff Traigle
Rick Garland
Honored Contributor

Re: How can I forward all local mail?

Depending on how many users we are talking about, this could mean some time and typing.

Create individual alias line items in the alias file that tells mail where to send.

Jeff_Traigle
Honored Contributor

Re: How can I forward all local mail?

Nah. That's what shell scripts are for. :) And in this case it could even be a one-liner for the initial setup. Assuming all user accounts should be forwarded, something like this should work:

awk -F: '{if ($3 > 99) print $1" : remoteuser@mail.server"} /etc/passwd >> /etc/mail/aliases

Then run the newaliases command to get then in the database for sendmail to process.
--
Jeff Traigle
Jeff_Traigle
Honored Contributor

Re: How can I forward all local mail?

Nah. That's what shell scripts are for. :) And in this case it could even be a one-liner for the initial setup. Assuming all user accounts should be forwarded, something like this should work:

awk -F: '{if ($3 > 99) print $1" : remoteuser@mail.server"} /etc/passwd >> /etc/mail/aliases

Then run the newaliases command to get them in the database for sendmail to process.
--
Jeff Traigle
Pedro Cirne
Esteemed Contributor

Re: How can I forward all local mail?

Hi,

Thank you all!

Enjoy :)

Pedro