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: <>

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

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: <>

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 while achieving this.

This is not at all unlike e-mail addresses. Even though the admin of my mail server might have named it, e-mail accounts are known to be 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

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 when in MessageSend() I only specify the user part (pjsip:user) of the address.

Where is Asterisk getting the domain name to append to the use user?

Hi Brian,

I just saw your post; I’m not sure I fully understand your question, however, I’ve navigated using MessageSend with pjsip a bit. Maybe I can help further if you clarify where the ${ACTUALTO} variable is set, but until then maybe this helps:

MessageSend uses a variable ${MESSAGE(to)} … you can use that variable to create your own variable like {ACTUALTO} that would include the intended user domain. Then use MessageSend to send to your new custom variable like:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.