Monday, 28 February 2011

Overloaded Postfix Mail Queue

No problems:

Copied here as it is just so useful!

Postfix Flush the Mail Queue

by VIVEK GITE on OCTOBER 25, 2007 · 12 COMMENTS

Traditionally you use the "sendmail -q" command to flush mail queue under Sendmail MTA. Under Postfix MTA, just enter the following command to flush the mail queue:
# postfix flush
OR
# postfix -f

To see mail queue, enter:
# mailq

To remove all mail from the queue, enter:
# postsuper -d ALL

To remove all mails in the deferred queue, enter:
# postsuper -d ALL deferred

postfix-delete.pl script

Following script deletes all mail from the mailq which matches the regular expression specified as the first argument (Credit: ??? - I found it on old good newsgroup)

#!/usr/bin/perl   $REGEXP = shift || die "no email-adress given (regexp-style, e.g. bl.*\@yahoo.com)!";   @data = qx; for (@data) {   if (/^(\w+)(\*|\!)?\s/) {      $queue_id = $1;   }   if($queue_id) {     if (/$REGEXP/i) {       $Q{$queue_id} = 1;       $queue_id = "";     }   } }   #open(POSTSUPER,"|cat") || die "couldn't open postsuper" ; open(POSTSUPER,"|postsuper -d -") || die "couldn't open postsuper" ;   foreach (keys %Q) {   print POSTSUPER "$_\n"; }; close(POSTSUPER);  

For example, delete all queued messages from or to the domain called fackspamdomain.com, enter:
./postfix-delete.pl fackspamdomain.com
Delete all queued messages that contain the word "xyz" in the e-mail address:
./postfix-delete.pl xyz

Tuesday, 8 February 2011

Installing PostgreSQL 9.0.3

Not quite so straight forward as no package is available and this didn't work for me (still couldn't find package) :(.

This may come in useful if your installing Ubuntu from scratch.

So (summarised from here, which for some reason isn't quite right and pieced together from various other sources):


aptitude install libreadline5-dev
aptitude install zlib1g-dev
./configure
make
make install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
logout
cp contrib/start-scripts/linux /etc/init.d/postgresql
update-rc.d postgresql defaults
chmod 755 /etc/init.d/postgresql
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
usermod -d /usr/local/pgsql/ postgres
/etc/init.d/postgresql start
(reboot if you want to test start script... "ps aux | grep postgres" to see if it is running)
su - postgres
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
#(ctrl z to exit)
logout

To access remotely you'll need to edit hba.conf (use md5 not trust - though you won't be able to connect remotely as postgres and will need to create your own user for remote access) and edit postgres.conf - listen_addresses = '*'