qmail sorry,_i_wasn’t_able_to_establish_an_smtp_connection

Lot of people got frustrated by this message. And I am not an exclusion.
As I understood from Google results, this happens mostly on setups with Parralels installed.
Mine is similar:
– virtual guest
– postfix is responsible for incoming mail
– qmail deliver outcoming mails.

The problem actually appears, when qmail tries to deliver e-mails to domain hosted on the same server.
Let’s consider the following example:
You have a domain example.com, which is fully hosted on your server. Also you have a web page (let it be php, but can be verified by simple mail command line application), which is intended to send e-mails to some info@example.com.
You have correct mapping in /etc/postfix/virtual:

where info_example_com is a special user, created to receive your e-mails.
Sending from outside of the server works like charm, sending from server to outside e-mail also works like in a fairy tail.
BUT, sending from your site example.com to your e-mail info@example.com doesn’t work at all. And log /usr/local/psa/var/log/maillog repeatedly reports the message:
sorry,_i_wasn't_able_to_establish_an_smtp_connection

I found a source of the problem and a solution for it.
The problem is, that qmail cannot contact port 25, while it is occupied by postfix. You should choose, which transport to use.
But if you are as lazy as I am, then there is a workaround here. We can make qmail deliver directly to your user’s Maildir.
1. edit /var/qmail/control/locals. Add there your domain example.com. If you host more than one domain, add them in rows.
2. edit /var/qmail/control/rcpthosts. Add there your domain example.com. If you host more than one domain, add them in rows.
3. edit /var/qmail/control/virtualdomains. Add there your domain example.com. If you host more than one domain, add them in rows.
4. add alias rule to /var/qmail/alias/.qmail-info, just enter there your user, which is intended to receive the e-mails for info@example.com. Note: this works for one domain. for multiple, reconsider the structure.

After this you will get your locally delivered e-mails directly to Maildir/new of your users.