Postfix: sending email copies of all incoming and outgoing mails to another domain or account

How to send an BCC copy of every incoming and outgoing email to another account? This is fairly simple to do with postfix. First open you main.cf and add or edit following lines:

# vim /etc/postfix/main.cf

now add these two lines:

sender_bcc_maps = regexp:/etc/postfix/archive_domain
recipient_bcc_maps = regexp:/etc/postfix/archive_domain

just a small explanation:

sender_bcc_maps is a regex based text file containing the mapping for outgoing mail
recipient_bcc_maps is a regex based text file containing the mappings for incoming mail

and here is an example line in the archive_domain file:

/^([^@]+)\@example\.com$/    $1@archive.example.com

the above line explained: every user @example.com will have a BCC copy send to that user @archive.example.com

 

Setting Apache2.2 prefork settings correctly

Apache's memory consumption is regulated by the spawned server processes and can easily consume all of your servers memory. If the prefork-module is used following paramters needs to be configured in your httpd.conf:

StartServers          18
MinSpareServers       3
MaxSpareServers       6
ServerLimit           60
MaxClients            60
MaxRequestsPerChild   4000

Now to get this parameters right use the following script to determine the actual memory consumption of one apache child process:

​pgrep httpd | xargs -n1 -I{} cat /proc/{}/smaps | awk '{if ($0 ~ /stack/) {pids+=1} else if ($0 ~/^Shared_/) {shared+=$2} else if ($0 ~ /^Pss:/) {priv+=$2}} END {printf "%.2f MB\n",(priv+shared/(pids*pids))/1024}'

Now to get MaxClients simply take the amount you want to give to apache and divide it with the consumption of one process, depending on the actual load the results may vary. Typically one process took between 30MB and 50MB. The above mentioned configuration is set for 3GB RAM (3*1024MB). Here a thumbrule:

StartServers          = 30% of MaxClients
MinSpareServers       = 5% of MaxClients
MaxSpareServers       = 10% of MaxClients
ServerLimit           = MaxClients
MaxClients            = total memory / one process memory (round down to be safe)
MaxRequestsPerChild   4000

Generating a Unique DH (Diffie-Hellman) Group

Due to a recent D(iffie)H(ellman) attack possibility called LogJam on lower paramter lengths like 512 bit and maybe, in short future, 768 bit, here the command to create a real strong parameter of 4096 bit:

openssl dhparam -out dhparams.pem 4096

 

Please be aware that this key creation can take up to 20 minutes and evern longer depending on your CPU.

Most software (apache, postfix, sendmail, dovecot etc) have config parameters where you can set the Diffie-Hellman group file. The DH algorithm is used to create secure keys when using connections over SSL/TLS.

More information about configuring different servers can be found here.