Operating System - HP-UX
1833051 Members
2475 Online
110049 Solutions
New Discussion

Re: How to send mail to another server at sheduled time

 
SOLVED
Go to solution
Jestin John Chacko
Regular Advisor

How to send mail to another server at sheduled time

Dear,

I want to sent the output of /var/mail/root to another server in the same ip range through mail configuration.

Is it possible to do that as if whenever the mail is generated in first server it should be transferred to the second one through this mail system.

Is there any script available for the same???


waiting for the reply

Jestin
7 REPLIES 7
Steven E. Protter
Exalted Contributor
Solution

Re: How to send mail to another server at sheduled time

Shalom,

Use cron.

http://docs.hp.com/en/B2355-90164/apcs01.html

after script name entry in crontab edit | mailx -s "subject" email@your.net

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
OldSchool
Honored Contributor

Re: How to send mail to another server at sheduled time

"How to send mail to another server at a scheduled time"

"I want to sent the output of /var/mail/root to another server in the same ip range through mail configuration."

"Is it possible to do that as if WHENEVER THE MAIL IS GENERATED in first server it should be transferred to the second one through this mail system."


those are three different requirements. the second one may be the easiest to address, but which is it you want to do????
OldSchool
Honored Contributor

Re: How to send mail to another server at sheduled time

actually I meant to say the 3rd requirement...
Mel Burslan
Honored Contributor

Re: How to send mail to another server at sheduled time

Your message title and the content of your question is quite conflicting.

If you want to send the root mail to a user on another server, this can be accomplished by setting an mail alias for root in the /etc/mail/aliases, such as :

root:user1@server1.mydomain.com,user2@server2.anotherdomain.com

save the file then run the command:

newaliases

now everything that comes to root's mailbox will be forwarded to user1@server1.mydomain.com and user2@server2.anotherdomain.com


If what you want is to forward root mail to another user at a certain time in the day, you can do that by using cron but it will need a little bit of more effort to get each email from the root's mailbox first, then send it to the user on the other server one-by-one.

Hope this helps
________________________________
UNIX because I majored in cryptology...
Jestin John Chacko
Regular Advisor

Re: How to send mail to another server at sheduled time

Dear,
Sorry for the confusing ...

i need the output for the second one can you specify the steps..
Jestin John Chacko
Regular Advisor

Re: How to send mail to another server at sheduled time

Dear Mel,
I am pasting the aliases file

cat aliases
##
# Sendmail Alias File
# @(#)B11.23_LRaliases $Revision: 1.1.212.1 $ $Date: 99/09/13 15:13:16 $
#
# Mail to an alias in this file will be sent to the users, programs, or
# files designated following the colon.
# Aliases defined in this file will NOT be expanded in headers from
# mailx(1), but WILL be visible over networks and in headers from
# rmail(1).
#
# >>>>>>>>>> The program "/usr/sbin/newaliases" must be run after
# >> NOTE >> this file is updated, or else any changes will not be
# >>>>>>>>>> visible to sendmail.
##

# Alias for mailer daemon
MAILER-DAEMON : root

# RFC 822 requires that every host have a mail address "postmaster"
postmaster : root

# Aliases to handle mail to msgs and news
nobody : /dev/null

# System Admistration aliases
operator : root
uucp : root
daemon : root

# Ftp maintainer.
ftp-bugs : root

# Local aliases


How i can do changes according to which you had mentioned in this file, can you specify it .Its my request because its a live server....
Mel Burslan
Honored Contributor

Re: How to send mail to another server at sheduled time

So, according to your response, you need to send root's mail from this server to another user at a certain time (let's say 5 PM) everyday then clean out the root's mailbox. If this is what you want and you really do not care how the mail looks when you need to read it (because it will come as a huge blob of data instead of individual mail messages)

put the following lines in a script

uuencode /var/mail/root root | mailx -m -s "Your mail subject here" someuser@someserver.com
> /var/mail/root
# first line, starting with uuencode and ending with .com
# (yes it should be on one single line) above
# takes the root's mailbox, encodes it to be attached and sends it to
# someuser@someserver.com as an attachment.
#
# second line, starting with ">" will clean root's mailbox for the next day.

then edit your crontab with "crontab-e" command and append this line to it:

0 17 * * * /path/to/my/scriptfile > /dev/null 2>&1

save and exit

Everyday at 5 PM, the mailbox file of the root user will be delivered to someuser you specified as one single attachment file. It is a text file but when you need to read it, you will need to convert it to dos format for the line breaks to look okay. There are many free utilities to do that on windows. Just google the term unix2dos

On the other side, if you want each message to be delivered to you as one single message at 5 PM, then you will need to write a script, to get messages one-by-one, convert them into individual text files (instead of one big blob) and send those text files as individual mail messages, but I unfortunately do not have time to devise a script for this. Maybe someone else have already done this and can help you with that, if this is what you exactly want.

Good luck.
________________________________
UNIX because I majored in cryptology...