Posted in Linux, Mail, One-Liners, Plesk, qmail on December 1st, 2009 by Rugmonster – Be the first to comment
I needed to remove messages older than a week old for a list of email accounts on a Plesk system running Qmail. I put together the following BASH script to locate the messages using find and back them up outside of the mailbox (just in case). This builds on the technique I used in my previous post, Maintain directory structure copying `find` results.
All you need to do is create a file with one address per line to be read in by the command.
cd /var/qmail/mailnames; \
IFS="@"; \
while read LINE ; \
do \
ADDR=( ${LINE} ); \
echo "${ADDR[0]}@${ADDR[1]}"; \
find ${ADDR[1]}/${ADDR[0]}/Maildir/ \
\( -path "*/cur/*" -o -path "*/new/*" \) \
! -type d -mtime +7 | \
while read FILE; \
do \
DIR=$( dirname ${FILE} ); \
mkdir -p /path/to/dst/${DIR}; \
mv ${FILE} /path/to/dst/${DIR}; \
done; \
done < /path/to/address_file
Posted in Linux, One-Liners on November 27th, 2009 by Rugmonster – 1 Comment
Let’s say you have a directory structure consisting of files owned by various users, but you want to copy only the files of a particular user to another path, but maintain the directory structure in the destination path. If you just use something like this…
find /path/to/src/ -user foo -exec cp -a {} /path/to/dst/
…you end up with all of the files in /path/to/dst/ with the original directory structure flattened out.
I came up with the following to solve the problem:
find /path/to/src/ -user foo | while read FILE \
do \
DIR=$( dirname ${FILE} ); \
mkdir -p /path/to/dst/${DIR}; \
cp -d --preserve=mode,ownership,timestamp ${FILE} /path/to/dst/${DIR}; \
done
Here’s a brief explanation. Since the find command returns the relative path of the matching item in it’s STDOUT, we can use the dirname command to get the original relative directory name. We then create the directory if it doesn’t exist, and finally do the copy.
Posted in Uncategorized on May 29th, 2009 by Rugmonster – Be the first to comment
A client today had a problem with Squirrelmail giving the following error, preventing the folder listing from coming up:
Query: CREATE "Sent"
Reason Given: Invalid mailbox name.
read more »
Posted in qmail on May 17th, 2009 by Rugmonster – 1 Comment
A couple of weeks ago at work, I was arguing which RBLs should be used with Plesk came up. I had always assumed that Plesk’s qmail setup would allow authenticated users regardless of any RBL results. If that were the case, then using zen.spamhaus.org wouldn’t pose any problem to mail users on a residential Internet service. I was wrong, but I wanted to sort out why and what options were available. read more »
Posted in Postfix on March 8th, 2009 by Rugmonster – 2 Comments
The battle between email admins and spammers is an ongoing arms race. The spammers are at a disadvantage because by and large, they have to rely on exploiting vulnerable systems to send their mail. With the ever growing size of botnets, they have a pretty large pool of exploited systems to send from, but Postfix can be configured to weed out most of that.
read more »