First of all,modify /etc/postfix/main.cf ,append the following line to the end of it:
header_checks = regexp:/etc/postfix/header_checks
body_checks = regexp:/etc/postfix/body_checks
To add an item to the blacklist:
For example,you want to filter away coming mails that contain words ‘A funny game’ in the subject,and to reject the mail to the sender,then do as the follows:
Type in /etc/postfix/header_checks:
/^Subject:.*A funny game/ REJECT drop header deny
List of actions:
REJECT : return the mail to the sender;
WARN : receive the letter,and log the information of the matter;
DISCARD : discard the mail,and give no reflection to the sender.
Then,using postmap to test the configuration:
postmap -q – regexp:/etc/postfix/header_checks < /etc/postfix/header_checks
Then reload postfix if no errors prompts:
To test the theory,I send a mail using my gmail account,in which the subject of the mail is ‘anotherhi,A funny game’.If it works,the mail should be rejected by the mail server.After I’ve sent the mail,I can get the response of the mail server:
tail -f /var/log/mail.info:
Oct 21 04:52:14 newserver6484 postfix/smtpd: connect from mail-qy0-f170.google.com[22.214.171.124]
Oct 21 04:52:15 newserver6484 postfix/smtpd: 0B8077529A5: client=mail-qy0-f170.google.com[126.96.36.199]
Oct 21 04:52:15 newserver6484 postfix/cleanup: 0B8077529A5: reject: header Subject: anotherhi,A funny game from mail-qy0-f170.google.com[188.8.131.52]; from= to= proto=ESMTP helo=: 5.7.1 drop header deny
#notice here,the mail is rejected by the mail server
Oct 21 04:52:15 newserver6484 postfix/smtpd: disconnect from mail-qy0-f170.google.com[184.108.40.206]
In my gmail account,I get a undelivered mail report as follows:
Technical details of permanent failure:
Google tried to deliver your message, but it was rejected by the recipient domain. We recommend contacting the other email provider for further information about the cause of this error. The error that the other server returned was: 550 550 5.7.1 drop header deny (state 18).
#notice the phrase here :’drop header deny’.
OK,success!Next we’re going to add an item to the whitelist.
To add an item into the whitelist:
Locate ‘smtpd_recipient_restrictions’ and type in the following content next to it：
check_recipient_access hash:/etc/postfix/to_white_list, #don’t lose the comma
The content of the file to_white_list is the items of your whitelist,for example:
[email protected] OK
After the above operations,[email protected] is then OK to send mail to your mail server.
In postfix by defaults,if one same ip has more than 4 pop3/imap clients to simutaneously receiving letters from(for example,your company has 5 people to connect to the same mail account to receive letters),the server will report the following errors in log file mail.err:
tail -f /var/log/mail.err:
Oct 21 04:27:31 newserver6484 couriertcpd: Maximum connection limit reached for ::ffff:1xxx.xxx.xxx.xxx
#xxx is the busy ip address,may be your company’s ip address
To avoid the errors,do as the follows:
vim /etc/courier/pop3d #modify MAXPERIP=40,by default 4
After the above operations,using tail -f /var/log/mail.err to see the result.Yes,no errors logged in the file any more.
Requirements as follows:
I’ve got a task to determine whether the tons of urls has 301 redirection.Tons of urls,yes,that’s what it means,cause you know,about 350 urls.I’m first mad at the task,but then,I tried and get the much more high efficiency way by using bash shell.
The theory of the method is:Using curl with option -I,we can get the header response of the url.If the response contains a line of ‘Location:’,then we can conclude that the url 301 redirects to another site. Read more…
Sometimes,for a variety of reasons,the customer service representatives’ mail account can no longer used because of the banned old mail server.In this case,we must set up new pop/imap and smtp mail server in order to let the old mail account go on working.
However,after we’ve set up the new mail server and users can log in the mail system,you’ll get the complaints from your colleagues that they lost some of the former mails from the customers.Yes,that circumstance exists if your colleague just not pull letters from the old mail server in their MUA before the time it crashed.In order to quiet down your staff,you may do as follows:
cp /var/qmail/mailnames/olddomain.tld/service/Maildir/new/* /var/qmail/mailnames/newdomain.tld/service/Maildir/new #copy & re-save
chown -R popuser:popuser /var/qmail/mailnames/newdomain.tld/service/Maildir/new
#take care to chmod directory permissions,for cp operation will make the owner to root
After the operations,you can notify your colleagues to receive letters from [email protected] now.And,the most important,contents include [email protected] that are ‘lost’ formerly complained by them.(the same to postfix)
Notice:In this example,two domains are on the same mail server. Read more…
Here I’m going to elaborates php session mechanism:files(files mechanism is also the most frequently used one).
In php.ini,session.save_handler = files instruct php using files mechanism in processing session.The files mechanism creates files in directory set by session.save_path in php.ini,and the filename is the cookie value on the client’s side(cookie name is set by session.name in php.ini,PHPSESSID by defaults),for example,70mild37sara2jpa2rk3h8bjg1.To get the cookie value on the client’s side,you go the follow steps in firefox(Or other browsers):Tools-Page Info-Security-View Cookies.Find the cookie name labeled PHPSESSID,click on it,and get the value of it.
On the server side,after the session’s filename is ready,then time for the content of the session.You set the session content in PHP by using the $_SESSION global variable,for example,$_SESSION['email']=’[email protected]’,$_SESSION['firstname']=’ff.Besides,you can use session_id([string $id]) to assign session id manually before session_start() turns up in your code. Read more…
mysql -h localhost -u root -pyourpassword
set password for ‘root’@'localhost’ = password(’123456′);
CREATE DATABASE `databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;