At last, it works!
What helped me a lot:
http://linuxconfig.org/configuring-gmail-as-sendmail-email-relay -> to configure sendmail
At the bottom there is said about FCDN, and link follows to
http://forum.linuxcareer.com/threads/1697-Sendmail-quot-unqualified-hostname-unknown-sleeping-for-retry-unqualified-hostname -> to fix hanging while sending message
I edited my /etc/hosts like that
127.0.0.1 localhost.localdomain localhost ubuntu-srv-moodle
127.0.1.1 ubuntu-srv-moodle
#here is another info, leave it as is, edit first line
Added "localhost.localdomain" and "ubuntu-srv-moodle" to first line. "ubuntu-srv-moodle" is my server's name.
That allowed mail send messages instantly, without awaiting for something (it says what it waits in system log file).
Now I enter in terminal
mail example@gmail.com
it prompts for Cc: - leave it blank, hit Enter
Then prompts for Subject: - enter here something like "Test1" and hit Enter
Then from newline type "Test1 text." Hit Enter.
On new line press Ctrl+D, and message should be sent immediately.
Then try again configure e-mail in Moodle.