Coercing recipient address domain in MessageSend()

I am using MessageSend() to send SIP SIMPLE MESSAGEs to users.

When I have a dialplan entry such as:

exten => s,n,MessageSend(pjsip:user,${ACTUALFROM})

the To: in the MESSAGE message is:

To: <sip:user@pbx.example.com>

The problem is that the users actually know, and tell their SIP clients that the Asterisk service is @example.com and through the magic of SRV records, their SIP clients finds the service at pbx.example.com.

Without getting into the details of the SIP client and how it keeps incoming and out going messages in the same context, suffice it to say that it wants the To: address to have the same domain as it knows the account to be at such that it receives it’s MESSAGE with:

To: <sip:user@example.com>

So the question is, is there any way to coerce that? Ideally (I think – I’m willing to be convinced otherwise though) I’d like to maintain the Asterisk’s service name as being pbx.example.com while achieving this.

This is not at all unlike e-mail addresses. Even though the admin of my mail server might have named it foobar.example.com, e-mail accounts are known to be user@example.com. That’s the address that people send mail to reach users on that server and that’s the address that users on that server use to send their mail from.

MX records tell the world which actual server to send mail to for a domain, just like SRV records tell a SIP client the actual server name to use to log in.

But ultimately the outward presence of those e-mail entities is user@domain.com.

It’s not unreasonable for all of this to be paralleled into the SIP SIMPLE world.

The question is just how to make Asterisk do it.

I am using Asterisk 13.38.1.

No ideas here? :frowning:

Maybe can somebody tell me how Asterisk constructs the recipient address sip:user@pbx.example.com when in MessageSend() I only specify the user part (pjsip:user) of the address.

Where is Asterisk getting the domain name pbx.example.com to append to the use user?