Archive for July, 2010

use “checkInstall” instead of “make install”

July 22nd, 2010

as said:

CheckInstall keeps track of all files installed by a “make install” or equivalent, creates a Slackware, RPM, or Debian package with those files, and adds it to the installed packages database, allowing for easy package removal or distribution.


set up postfix on debian

July 13th, 2010

Suppose you have 2 sites: & And you would like to set as a local domain, and as a virtual domain. That means emails of will go to the system user’s personal mail dir while has no actual corresponding system user. Details about local domain & virtual domain, please see paragraph “Virtual domains versus local domains” at

part 1: configure local domain

  • install postfix
    apt-get install postfix
  • config postfix
    add the domain to config files using psotconf:
    postconf -e "myorigin ="

    add hostname:
    postconf -e ""
  • Reload Postfix Server:
    postfix reload

Now you can try to send a email via telnet.
telnet localhost 25
You should see:

Connected to localhost.
Escape character is ‘^]’.
220 ESMTP Postfix (Debian/GNU)

Now send a test mail to yourself:

mail from:<>
rcpt to: <>
Subject: First test mail to yourself
Damn it! It worked! Hahahahaha…

End the input with an enter, then a dot “.”, and an enter again.

And then quit:

Now use mail to check your email.

part 2: configure virtual domain

  • create a user and take his home dir as the virtual server’s base dir.
    #> groupadd -g 5000 vmail
    #> useradd -g vmail -u 5000 vmail -d /home/vmail -m
  • set the virtual_uid_maps and virtual_gid_maps to these IDs:
    #> postconf -e virtual_uid_maps=static:5000
    #> postconf -e virtual_gid_maps=static:5000
  • add as a virtual domain into virtual_mailbox_domains
    #> postconf -e
  • set the base dir
    #> postconf -e virtual_mailbox_base=/var/spool/vmail
  • reload postfix
    #> postfix reload;
  • add virtual email addresses
    • tell which file the email addresses are stored in
      #> postconf -e virtual_mailbox_maps=hash:/etc/postfix/vmailhost
    • create the file and add some addresses in there.
      #> vi /etc/postfix/vmailhost
      with content like this:

      So, the mail files for service will actually be stored in /home/vmail/, and mail files for webmaster will be in /home/vmail/
    • Now, map the file into DB
      #> postmap /etc/postfix/vmailhost
  • Probably you also need to create the dirs for these 2 addresses
    mkdir /home/vmail/
    #> mkdir /home/vmail/
    #> cd /home/vmail/
    #> mkdir new curr tmp
    And do the same for
  • change the owner and permissions if you created this folders manually and with ROOT privilege:
    #> chown -R vmail:vmail /home/vmail/
    #> chmod -R 700 /home/vmail/

OK, now you can send mail via telnet to have a test.

part 3: configure alias for

If you want to forward received mails of, you can use a alias to forward to your another email address, let’s say

  • tell where is the alias configuration file
    #> postconf -e "alias_maps = hash:/etc/postfix/aliases"
    postfix reload;
  • add forward rules in the file:
    #> vi /etc/postfix/aliases
    with the conetent:
    and map it:
    #> postmap /etc/postfix/aliases


  • Every configuration done by postconf, you can actually do it by editing /etc/postfix/ directly.
  • Every time you change with command postmap, do not forget to reload postfix with: #> postfix reload.
  • Every time you change a db file, do not forget to re-postmap it with: #> postmap /etc/postfix/xxxxx.
  • If you want to set both sites into virtual server, only set localhost as your destination and both sites into virtual domain.

Important debug method

First, all check the log which should be /var/log/mail.log, no matter you want to find the cause of the failure or to check that your email is sent/received successfully.

Second, use mutt to try to send/receive emails

Important references


———————– v1.1: 27/08/2010 ————————

How to add SASL auth

atually a complete instruction for install postfix on debian
official postfix manual

———————– v1.2: 27/08/2010 ————————

How to set up SPF

———————– v1.3: 03/09/2010 ————————

How to set up domain keys & dkim

Setting up domain keys with dkfilter:

Note: as the dkfilter author has said, dkfilter is deprecated now and DKIMproxy is recommended.

Follow this link : except the settings in file /etc/postfix/ should be:

pickup    fifo  n       -       n       60      1       pickup
    -o content_filter=dksign:[]:10027

And, you may also need to add these as said in

# modify the default submission service to specify a content filter
# and restrict it to local clients and SASL authenticated clients only
submission  inet  n     -       n       -       -       smtpd
    -o smtpd_etrn_restrictions=reject
    -o smtpd_sasl_auth_enable=yes
    -o content_filter=dksign:[]:10027
    -o receive_override_options=no_address_mappings
    -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject

# specify the location of the DomainKeys signing filter
dksign    unix  -       -       n       -       10      smtp
    -o smtp_send_xforward_command=yes
    -o smtp_discard_ehlo_keywords=8bitmime

# service for accepting messages FROM the DomainKeys signing filter
# inet  n  -      n       -       10      smtpd
    -o content_filter=
    -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
    -o smtpd_helo_restrictions=
    -o smtpd_client_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o mynetworks=
    -o smtpd_authorized_xforward_hosts=

How to generate key:

perl -MMIME::Base64 -e 'print encode_base64("cihangcihangpassword");'

How to test:

telnet localhost 25
ehlo localhost
auth plain Y2loYW5nAGNpaGFuZwB4TDM4MjVNdjZ1

Setting up Domain Keys and/or DKIM with DKIMproxy:

didn’t try. see here: Mail-DKIM and DKIMproxy.

how to make a hyperlink to a cell in OpenOffice Calc

July 7th, 2010

just make the link like this: #SheetName.$Column$Row

loop through json object

July 2nd, 2010

p = {k1: v1, k2, v2, k3, v3};
for (var key in p) {
if (p.hasOwnProperty(key)) { // make sure that the key you get is an actual property of an object, and doesn’t come from the prototype: