Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Sharing mailboxes with Mail.app Apps
Say you are sharing a computer with a number of people (say your family), and you want to be able to share a common mailbox. It turns out that with a little work, this can be done using MacOS X (PB) and Mail.app. But it does take a little work, some time with terminal.app, and the root password.

Read the rest of this article for detailed instructions on how to set up a mailbox that can be used by more than one user. [Editor's note: I have not tried this on my machine yet, but it looks fairly straightforward.]

Step One:First setup the mail account normally for the first user. Including password, etc. You can set the options however you like. One thing to consider when choosing who this user is, is that everyone else who has a login on this computer will be theoretically able to view all of the mail from this person (if they play around a little). You may want to create a dummy login for this purpose only. At this point you will want to create any Saved Mail Mailboxes that you might want to share between users.

For the rest of this tip this account will be called dummy. Wherever you see dummy, just fill in the appropriate login name in your case.

Step Two:Because Mail.app does some weird things with it's files (does not remember permissions), we are going to have to make a small script that corrects for this every ten minutes. We are going to do this using Terminal.app, and a part of the Operating System called 'cron' (technically a service).

Open up a Terminal.app session (Terminal.app is found in the Utilities folder in the Applications folder). This should bring up a window with a prompt, something like this:
[localhost:~] yourUserName%
In order to do the work we are going to do we need to be root, so we are going to use 'su' to become root inside this window. To do this type 'su return' at the prompt.

You will then be asked for a password. The password it is looking for is the root password (it is the same as the first one you gave while setting up the machine in the first place). Once you enter the password correctly you will get a new prompt, one that looks like this:
[localhost:/Users/yourUserName] root#
Now we are going to change into another folder. To do this type cd /usr/share return. Now your prompt should look like:
[localhost:/usr/share] root#
I have chosen this location fairly arbitrarily, and almost anyplace would work, but then you would have to change other things. If you know what you are doing, you will know the changes to make, otherwise, just follow along, you will learn those things later, if you want to. Now, to create the script type pico mailAdjust.sh. And then type in this:
#!/bin/sh

# this is just littel script that will make sure that everyone
# can use this mailbox

chmod -R 777 /Users/dummy/MailAccounts/POP:emailAddress@host.name;
chmod -R 777 /Users/dummy/Mailboxes;
In place of dummy type the name of the account you have already setup, and in place of emailAddress@host.name, type in the email address belonging to this account (ie. someone@here.com). To finish creating this file, type control-X. You will be asked if you want to 'save modified buffer', answer yes by typing 'y', and then when it asks 'File Name to write:', accept the suggestion of 'mailAdjust.sh' by hitting the return key (we gave it that suggestion earlier).

Step Three: Setting up a cron entry. Now you should be back at command prompt ([localhost:/usr/share] root#). Type pico /etc/crontab. This will bring up the crontab file for editing. We are going to add a couple of lines to the bottom of this file. Use the arrow keys to go to the bottom of the file, and then add these two lines:
# setup for sharing a mailbox
*/10 [tab] * [tab] * [tab] * [tab] * [tab] root [tab] /usr/share/mailAdjust.sh
NOTE: Do not type the [tab] keystrokes; simply hit the tab key.

The first line is a comment as it starts with a '#'. Comments are a really good idea when you are working with configuration files. The second line is the part that tells cron to run the little script we created every tenth minute (six times an hour) of every hour of every day of every month, etc, and to run it as the root user.

To save our changes to this file, do exactly as we did before: type control-X. You will be asked if you want to 'save modified buffer', answer yes by typing 'y', and then when it asks File Name to write : accept the suggestion of '/etc/crontab' by hitting return (we gave it that suggestion earlier). We are done being with being root, so now type exit followed by a return, and you will get your normal prompt back (localhost:~] yourUserName%').

Step Four: Setting up the other users. Now that we have the dummy account done, we have to set up our other users so that they can use the account. To set up a user, we need to be loged in as that user, so at this point log in as one of those users. Now, setup Mail.app just as you did for the dummy account. Once you are done setting up Mail.app, quit out of it, and go back into Terminal.app.

Now we are going to edit the preferences file for Mail.app for this user. Type cd ~ and hit return. Make sure that your command prompt looks like '[localhost:~] yourUserName%' and that it does not mention 'root'. Now type pico Library/Preferences/com.apple.mail.plist and hit return. This should bring up a long file. Scroll down in that file to find this section:
      AccountName
Whatever you called the account
AccountPath
~/MailAccounts/POP:emailAddress@this.host
The only thing you have to change is to replace the '~' with '/Users/dummy', where 'dummy' is the name of the account you set up in Step One. Then you can close this file and save your changes just like you did twice before.

Now in order to also share the saved mailboxes we need to create links to them in the proper folder. To get to that folder type cd ~/Mailboxes and hit the return key. To list the mailboxes that you can share, type 'ls ~dummy/Mailboxes' and hit return. This will list all the mailboxes that dummy has, and that we have set up for sharing (see Step One).

For each Saved Mailbox that you want this user to see, type in 'ln [space] /Users/dummy/Mailboxes/ [space] ./mailbox.mbox' where 'mailbox.mbox' is one of the mailboxes listed in the previous step (it should end in '.mbox').

Once you are done with this, you can fire up Mail.app, and check to see that everything works. To add more users to this arrangement you only have to repeat Step Four for each of them.

The biggest problem/inelegancy of this tip is that if you get mail from one account, and then logout, and login with another account and fire up Mail.app before the clock has gone over a ten minute interval, you can beat the script to the punch, and the second person might only be able to open that mailbox read-only. If this happens, quit out of Mail.app, wait ten minutes, and start it up again. This shouldn't be a big problem, as most of the time people don't work like this, but... if it becomes too big a problem for you, change the crontab part of this tip to run the script more often.

I hope that this tip helps you out, and that Apple's next version of Mail.app is built with this sort of sharing in mind.
    •    
  • Currently 2.63 / 5
  You rated: 1 / 5 (8 votes cast)
 
[8,373 views]  

Sharing mailboxes with Mail.app | 1 comments | Create New Account
Click here to return to the 'Sharing mailboxes with Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
mail sharing
Authored by: robh on Jan 08, '01 12:07:43PM

I think there must be lots of easier ways to achieve this. How about:


If you're running a sendmail daemon rather than using POP/IMAP to fetch the
mail then one could just create an alias (e.g. in /etc/mail/aliases)
to map the shared email box name into the usernames of each
family member, so everyone gets sent a copy of the mail when it arrives.

If you are not running a sendmail daemon, use fetchmail to
retrieve the mail and then feed messages from fetchmail directly into /usr/sbin/sendmail
and again use an alias to send copies to each family member.
For help on fetchmail, try
man fetchmail in a terminal.


Mail.app preferences should then setup without a POP/IMAP entry -
leaving just a "Personal Mailboxes" entry which tells Mail.app to read new
mail from /var/mail/username.


Note that to use personal mailboxes under the public beta you need
to make /var/mail writeable by everyone but not trashable by everyone, otherwise
Mail.app fails because it can't modify your personal mailbox file (/var/mail/username) (note
this is a bug in Mail.app).
To change the directory permissions from a terminal, first change to the root user with
su (and respond with the root password) then type chmod 1777 /var/mail
and then exit to finish working as root.





[ Reply to This | # ]