--- channels/chan_sip.c.2011-02-02 2011-02-02 18:37:52.000000000 -0700 +++ channels/chan_sip.c 2011-02-02 21:52:20.000000000 -0700 @@ -20540,6 +20540,24 @@ if (peer) { mailbox = ast_strdupa(peer->unsolicited_mailbox); unref_peer(peer, "removing unsolicited mwi ref"); + /* Setting "unsolicited_notify=yes" is useful if the peer sends separate + * MWI NOTIFYs for each of the endpoints connected to us */ + if (!strcasecmp(mailbox, "yes")) { + /* Do not store voicemail in a bogus box named 'yes' */ + mailbox = NULL; + /* Parsing... Message-Account: sip:1234@1.2.3.4:5060;user=phone */ + char *d = ast_strdupa(get_body(req, "Message-Account", ':')); + if(d) { + char *actualmailbox = strchr(d, '@'); + if (actualmailbox) + *actualmailbox = '\0'; + actualmailbox = strchr(d, ':'); + if (actualmailbox) { + *actualmailbox++ = '\0'; + mailbox = actualmailbox; + } + } + } } } else { mailbox = p->mwi->mailbox;