Why do I get hostname: Name or service not known error?

run hostname --fqdn

If you get an error, edit /etc/hostname and /etc/hosts with a proper hostname.

Then aptitude install ssmtp again to get it to install.


Editing of /etc/hosts did the trick. The file /etc/hostname was correct with containing only server.exmaple.com

But the hosts was not correct

127.0.0.1 localhost
127.0.0.1 server

I changed it to this:

127.0.0.1 localhost.localdomain  localhost
192.168.xxx.xxx  server.example.com   server

then I ran hostname -f (short for hostname --fqdn) and got the following.

server.example.com

Solution:

(These types of problems don't have good solutions. But only some haking-ish)

You should first try this command in a terminal:

sudo apt-get -f install

If it doesn't work, process with haking-ish solution.

Try temporarily moving the configuration script of ssmtp.

  1. Open a terminal and execute this command to move them to the current dir

      sudo mv /var/lib/dpkg/info/ssmtp* .
    
  2. Then try using apt-get

The cause of the problem:

The previous installation or removal might not completed successfully, leaving some configuration step to be done for ssmtp package. Since, dpkg won't progress without first completing the steps, subsequent use of apt-get now get stuck on that step.