Change sender address
Add into main.cf
smtp_generic_maps = hash:/etc/postfix/generic
Then in /etc/postfix/generic:
apache info@mydomain.com
postmap /etc/postfix/generic
Restart postfix...
Queue manipulation
postfix start # start postfix postfix stop # stop postfix postfix reload # reload postfix like after changing the main.conf file mailq # see what mail is in the mail queue. same as command: postqueue -p postqueue -f # do a mail queue run and try to deliver the mail in the queue postqueue -s site # do a queue run for a certain "site" (domain) postsuper -d queue_id # delete a specific message from the mail queue by it's id. postsuper -d ALL # delete all mail from the mail queue postsuper -h queue_id # put a message in the mail queue on hold postsuper -H queue_id # take a message off hold postconf # shows you all the parameters (settings) of the running postfix
http://www.pantz.org/software/postfix/setuppostfix.html
Add subject line logging
In main.cf:
header_checks = regexp:/etc/postfix/header_checks
and in /etc/postfix/header_checks you write:
/^Subject:/ WARN
Some very basic anit spam stuff
/^From: "spammer/ REJECT
/^From: "ipupiice@aderispharm.com/ REJECT
/^Subject:.*viagra/ DISCARD
/^Subject: .*Make Money Fast!/ REJECT
#attachments
/^(.*)name=\"(.*)\.(exe|lnk|dll|shs|vbe|hta|com|vbs|vbe|js|jse|bat|cmd|vxd|scr|shm|pif|chm)\"$/ DISCARD
/^(.*)name=(.*)\.(exe|lnk|dll|eml|shs|vbe|hta|com|vbs|vbe|js|jse|bat|cmd|vxd|scr|shm|pif|chm)$/ DISCARD
#cs some more good ones
/^Subject: \{Virus\?\}/ REJECT Bogus antivirus warning (1)
/^Subject: Virus Detected by Network Associates, Inc\. Webshield/ REJECT Bogus antivirus warning (2)
/^Subject: ---- Virus Detected ----$/ REJECT Bogus antivirus warning (3)
/^Subject: Virus detected$/ REJECT Bogus antivirus warning (4)
/^Subject: Virus Alert$/ REJECT Bogus antivirus warning (5)
http://www.t29.dk/antiantivirus.txt
Then you issue a "postfix reload".
Check and amend message size limit
postconf -n | grep message_size_limit
postconf -d would show the default
Set to 20MB
postconf -e 'message_size_limit = 20971520'
/etc/init.d/postfix restart
Remove error messages from the mailq
mailq | grep MAILER-DAEMON | sed -e 's/!$//' | cut -d! -f 1 | postsuper -d -
Remove mail from a sender eg. double-bounces@example.com
mailq | grep double | cut -d" " -f1 | uniq > doubles
cat doubles
cat doubles | wc -l
postsuper -d - < doubles
Check the size of the mail queue:
mailq | tail -15
Display a message in a queue use
postcat <ID> | head -50
Remove all messages containing STRING
for MESSAGE in `grep -R STRING *|awk '{ print substr($3,1,12) }'`; do postsuper -d $MESSAGE; done
Remove all messages containing STRING (When there are subdirectories)
cd /var/spool/postfix/deferred/ [code]for MESSAGE in `grep -R STRING *|awk '{ print substr($3,3,12) }'`; do postsuper -d $MESSAGE; done
Flush queue
postfix flush
or postqueue -f
Re-queue all messages (ie requeue messages in all queues)
postsuper -r ALL
Remove all messages in deferred folder (/var/spool/postfix/deferred)
postsuper -d ALL deferred
Catching errors while changing postfix Chances are that configuration errors during implementation cause Postfix to bounce legitimate messages. Setting the soft_bounce parameter during integration and reloading the Postfix configuration afterwards prevents Postfix from bouncing legitimate mail during that time:
postconf -e "soft_bounce = yes"
postfix reload
As soon as soft_bounce has been activated Postfix will treat all delivery errors as temporary errors - any client that wants to send messages to Postfix will keep mail in the mailqueue and it will suspend delivery until the soft_bounce parameter has been removed or set to no. Once the integration of amavisd-new into the Postfix delivery process has been completed successfully soft_bounce must be removed or Postfix will not generate bounce messages for legitimate mail.
## Putting messages on hold and releasing ##
Put messages on hold that meet search criteria
mailq |grep "user@domain" |awk '{print $1}'|sed 's/\!//' > t for MESSAGE in `cat t`; do postsuper -h $MESSAGE; done]
Put all messages over 2Mb on hold:
cd /var/spool/postfix/active
for MESSAGE in `find ./ -type f -size +2000k|awk '{ print substr($1,3,12) }'`; do postsuper -h $MESSAGE; done
Release messages on hold that match a criteria
mailq |grep "user@domain" |grep "\!" |awk '{print $1}'|sed 's/\!//' > t for MESSAGE in `cat t`; do postsuper -H $MESSAGE; done
Check the sizes of the queues:
du -sh /var/spool/postfix/*
Check the amount of inbound messages ie by sending domain in the active queue:
qshape -s active (leaving out -s when you want to check by recpient)
Some tuning options (turning off scanning with amavis):
# Amavis support
# content_filter=amavisfeed:[127.0.0.1]:10024
header_checks = regexp:/etc/postfix/header_checks
data_directory = /var/lib/postfix
# cs Performance tuning
smtpd_error_sleep_time = 0
default_process_limit = 200
maximal_backoff_time = 6000
queue_run_delay = 900
minimal_backoff_time = 600
#disable_dns_lookups = yes
EExtract messages form the log file for a user: [code] cat maillog |grep "Mar 4" |grep -v "127.0.0.1" |grep -i "to="|awk '{print $6}'|tee - |egrep -f - maillog|grep -v "127.0.0.1" |grep -v "removed"[/code] Convert maildir to mbox format [code]#!/bin/bash for file in `find /home/user/{current.mdir,new.mbox}/ -type f` do cat $file | formail >> mbox done[/code] This will grab the mdir directory at /home/user/ and convert it to an mbox file at /home/user/new.mbox Squirrelmail Preferances http://www.squirrelmail.org/docs/admin/admin-5.html