Gammu is command line utility and library to work with mobile phones from
many vendors. Support for different models differs, but basic functions
should work with majority of them.  Program can work with contacts, messages
(SMS, EMS and MMS), calendar, todos, filesystem, integrated radio, camera,
etcetera.  It also supports daemon mode to send and receive SMSes.

gammu can optionally use postgresql.
