Operating System - HP-UX
1751960 Members
4735 Online
108783 Solutions
New Discussion юеВ

Re: sendmail / editing inboxes

 
SOLVED
Go to solution
Fred Martin_1
Valued Contributor

sendmail / editing inboxes

Occasionally I have a need to 'vi' a user's email inbox in /var/mail.

The way I have always done this is to make a copy of the inbox, edit the copy, then look in the original inbox for new email that may have come in (or out, w/pop3) while I worked.

If any differences I resolve them manually to my work copy and then put the copy back over the orginal.

Is there a better way, i.e. lock out the file so that sendmail/pop3 must wait?

Fred
fmartin@applicatorssales.com
4 REPLIES 4
Matti_Kurkela
Honored Contributor
Solution

Re: sendmail / editing inboxes

Yes. The trick is in knowing which locking method is used on any given system: there are several that might apply.

The traditional mechanism for Unix-style mailbox locking is to create a /var/mail/.lock file. If this file exists, the mailbox is locked. However, some programs will assume that if the lock file is older than 5 minutes, it is a stale lock file and will replace it with their own.

MK
MK
Fred Martin_1
Valued Contributor

Re: sendmail / editing inboxes

I should have mentioned that this is HP-UX v11.11 sendmail.
fmartin@applicatorssales.com
Dennis Handly
Acclaimed Contributor

Re: sendmail / editing inboxes

Just use mailx(1). This will automatically follow the correct locking protocol.

I don't think you can use "-f /var/mail/user-name", nor "-u user-name"?

You may have to just use:
MAIL=/var/mail/user-name mailx

You can use "h" to get a list of messages and then "e message-number" to edit. "z+" or "h number" to move forward.
The "q" to quit. "x" to abandon all changes.

Fred Martin_1
Valued Contributor

Re: sendmail / editing inboxes

Excellent, thanks folks.
fmartin@applicatorssales.com