Post.Office Tips & Tricks: Index
This is a very simple script that returns the path to the user directory for a given e-mail address.
Very often, I'm asked by a client to remove a message from their mailbox (it might be a corrupted message or several megabytes of attachments that they couldn't care less about.
I found it very time consuming to go into the web interface, lookup the user account and then find the correct path to their mailbox just to delete the file via the command line.
Therefore I wrote this little script which takes an e-mail address as input and then finds the correct mailbox directory.
Copy this script to a file on your server. Preferably into the home directory of root.
root# su -
root# cd ~root
root# touch checkuserdir.sh
root# chmod 755 checkuserdir.sh
root# echo 'alias checkuserdir "sh ~/checkuserdir.sh"' >> ~/.cshrc
And then insert the script into the checkuserdir.sh file you just created.
#!/bin/sh uid=`/usr/local/post.office/cmdutils/getuid $1` echo $uid popdir=`/usr/local/post.office/cmdutils/getpopmbox $uid` echo $popdir userdir=`echo $popdir"/in"` #end
When you log out of your root account and login again, you can use the script on the command line by typing:
root# checkuserdir user@domain.com
It returns following information:
User_Name /Volumes/Data/mailbox/81/User_Name
This makes it very easy to go into the user mailbox to remove any files or see what's going on...
root# cd /Volumes/Data/mailbox/81/User_Name/in/
root# ls -al[relay:81/User_Name/in] root# total 8 drwxr-x--- 6 mta mail 204 Jan 21 22:03 . drwxr-x--- 7 mta mail 238 Sep 11 22:33 .. -rw-rw---- 1 mta mail 0 Jan 21 22:03 __cache__ -rw------- 1 mta mail 0 Sep 11 22:33 __lock__ -rw-r----- 1 mta mail 8 Jan 21 22:03 __size__ -rw------- 1 mta mail 0 Sep 11 22:33 __size_lock__
Please support the development of these scripts through PayPal. Thank you.