Scripting

Mail Server Stuff

General useful information for administering mail

Generating a spam mail - send email with the following content :

 
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X 

to auto make this to a test file for easy testing make a file called spammail with the following :

 
ehlo localhost
mail from:test@example.com
rcpt to:<user email here>
data
 XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
.
quit

then to send the mail, simply :

$ telnet localhost 25 < spammail

you should see:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

Check your logs to see if it sent.

Forwarding mail caught as spam to a single mailbox :

1 - Create the mailbox

# su - vmail
$ cd yourdomain.tld
$ maildirmake spamadmin

2 - add user to users table or file :

$ mysql -u<user> -p<password> mail -e "insert into users values ('spamadmin@domain.tld', encrypt('<yourpassword>'), ......< add extra column data here depending on schema of your users table'

3 - add the following to /etc/postfix/main.cf :

header_checks = pcre:/etc/postfix/header_checks

4 - add the following to /etc/postfix/header_checks :

/^X-Spam-Flag: YES/                     REDIRECT spamadmin@domain.tld

5 - make sure that header checks are not disabled in your 'delivery' config (in /etc/postfix/master.cf)

127.0.0.1:10025 inet n - - - - smtpd
        -o content_filter=
        -o local_recipient_maps=
        -o relay_recipient_maps=
        -o smtpd_restriction_classes=
        -o smtpd_client_restrictions=
        -o smtpd_helo_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o mynetworks=127.0.0.0/8
        -o strict_rfc821_envelopes=yes
        -o receive_override_options=no_unknown_recipient_checks
        -o smtpd_bind_address=127.0.0.1

ie, make sure you dont have :

-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks