In my project, I want my raspberry PI to dial the outgoing PSTN.
I have a SIP account with a regular phone number assigned and I can make the mentioned outgoing calls on OSX using Telephone.app :

Now I tried to achieve the same thing on my raspberry PI using linphonec
First, I will register my SIP provider with linphone, which seems successful:
$ sudo apt-get install linphone $ linphonec linphonec> register sip: 4100000004@free4.voipgateway.org free4.voipgateway.org <PASSWORD> Registration on sip:free4.voipgateway.org successful.
Then I try to call 004100000018 with the error results.
linphonec> call 0041000000018 Establishing call id to <sip: 0041000000018@free4.voipgateway.org >, assigned id 1 Contacting <sip: 0041000000018@free4.voipgateway.org > Call 1 to <sip: 0041000000018@free4.voipgateway.org > in progress. Remote ringing. Early media. Call 1 with <sip: 0041000000018@free4.voipgateway.org > early media. Call declined. Call 1 with <sip: 0041000000018@free4.voipgateway.org > ended (Call declined).
I also tried +41 , not 0041 , but that didn't work either. PI is connected to the Internet, but I'm not sure if this is a problem with a proxy server or a firewall, or if I use linphone incorrectly.
Note: Usually I do not have to use linphone. Therefore, if there is another client that does not use the UI that would do the job and that I could use scripts or APIs in some way, then I would be more than happy to do this too.
Troubleshooting
I raised the level of the log and ran into:
ortp-error-eXosip_dnsutils_naptr_lookup: res_query failed ('free4.voipgateway.org NAPTR')
Then I found the following remark about this thread
Your exosip version may be old and buggy. You can try updating exosip and recompiling your version of linphone. Or better, the git clone phone and the new sip-stop cartridge.
So, I checked the linphonec version, and currently I got 3.5.2, while they advertise 3.8 on the site. So I will try to upgrade to version 3.7 with of this. this manual
Update
Similar questions on SO: