From 88de7ef67099988a857354d22da2e7dcbd3d5cfd Mon Sep 17 00:00:00 2001
From: bagyenda <>
Date: Fri, 14 Jul 2006 13:11:08 +0000
Subject: [PATCH] - Add MIME-Version header to email messages outgoing - check
for short code in globalsender before checking if local recipient
---
mbuni/doc/userguide.shtml | 10 ++--
mbuni/mmlib/mms_util.c | 3 +
mbuni/mmsc/mmsglobalsender.c | 113 ++++++++++++++++++-----------------
3 files changed, 66 insertions(+), 60 deletions(-)
diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml
index f2cf301..d800dcd 100644
--- a/mbuni/doc/userguide.shtml
+++ b/mbuni/doc/userguide.shtml
@@ -3165,16 +3165,16 @@ is discarded and the sender notified via delivery report.
If the message is due for delivery attempt, the global sender
determines, for each recipient, how to deliver the message:
-- If the message is destined for a local MMS client, the message
-is transferred to the mobile/local queue. A copy of the message is
-sent (as MIME) to the MMBox host (if one is configured)
- If the message is destined for an email user, the message is
re-formatted as MIME, sender and recipient addresses normalised as RFC
822 addresses, and the message passed to the mailer.
-
- If the message is destined for a foreign gateway, it is coded
-as MIME and passed to the mailer for delivery via SMTP
- If the the message is destined for a VASP (identified by short
code), then it is sent using MM7 protocols to the relevant VASP.
+
- If the message is destined for a local MMS client, the message
+is transferred to the mobile/local queue. A copy of the message is
+sent (as MIME) to the MMBox host (if one is configured)
+
- If the message is destined for a foreign gateway, it is coded
+as MIME and passed to the mailer for delivery via SMTP
- If the message cannot be delivered, the sender is notified.
diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c
index 27408fd..5842b1f 100644
--- a/mbuni/mmlib/mms_util.c
+++ b/mbuni/mmlib/mms_util.c
@@ -645,6 +645,9 @@ int mms_sendtoemail(Octstr *from, Octstr *to,
http_header_add(newhdrs, "From", octstr_get_cstr(from));
http_header_add(newhdrs, "To", octstr_get_cstr(to));
http_header_add(newhdrs, "Message-ID", msgid ? octstr_get_cstr(msgid) : "");
+
+ http_header_add(newhdrs, "MIME-Version", "1.0");
+
http_header_combine(newhdrs, m->headers);
http_destroy_headers(m->headers);
m->headers = newhdrs;
diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c
index c873e6c..3321355 100644
--- a/mbuni/mmsc/mmsglobalsender.c
+++ b/mbuni/mmsc/mmsglobalsender.c
@@ -207,66 +207,69 @@ static int sendMsg(MmsEnvelope *e)
goto done;
}
- /* Normalise the number, then see if we can resolve home MMSC for this recipient. */
- normalize_number(octstr_get_cstr(settings->unified_prefix), &phonenum);
-
- if ((mmsc = settings->mms_resolvefuncs->mms_resolve(phonenum,
- settings->mms_resolver_module_data,
- settings, proxyrelays))) {
- info(0, "mmsc for \"%s\" resolved to: \"%s\"",
- octstr_get_cstr(phonenum), octstr_get_cstr(mmsc));
-
- if (octstr_compare(mmsc, settings->hostname) == 0) {
- if (settings->mms2mobile) { /* Send a copy to this VASP. */
- Octstr *xerr = NULL;
- int res = mms_sendtovasp(settings->mms2mobile,
- e->from, to->rcpt,
- e->msgId,
- msg, &err);
- info(0, "%s Global Queue MMS Send: Local Msg copy to VASP (%s) - "
- "From %s, to %s, msgsize=%ld: err=%s",
- SEND_ERROR_STR(res),
- octstr_get_cstr(settings->mms2mobile->id),
- octstr_get_cstr(e->from), octstr_get_cstr(to->rcpt), e->msize,
- xerr ? octstr_get_cstr(xerr) : "(null)");
- if (xerr)
- octstr_destroy(xerr);
- }
-
- res = mms_sendtomobile(e->from, to->rcpt,
- e->subject, e->fromproxy,
- e->msgId, e->expiryt, msg, e->dlr,
- &err);
+ /* Search VASP list, see what you can find... */
+ for (j = 0, m = list_len(settings->vasp_list); j < m; j++)
+ if ((vasp = list_get(settings->vasp_list, j)) != NULL &&
+ _x_octstr_int_compare(vasp->short_code, phonenum) == 0) {
+ res = mms_sendtovasp(vasp, e->from, to->rcpt,
+ e->msgId,
+ msg, &err);
sent = 1;
- } else if (proxyrelays && list_len(proxyrelays) > 0) /* Step through proxies. */
- for (j = 0, m = list_len(proxyrelays); jhost, mmsc)) {
- res = mms_sendtoproxy(e->from, to->rcpt,
- e->subject, mp->host,
- e->msgId, e->expiryt, msg,
- e->dlr, &err);
- sent = 1;
- break;
+ break;
+ }
+
+ if (sent != 1) { /* Not yet, sent, find the receiver MMSC. */
+ /* Normalise the number, then see if we can resolve home MMSC for this recipient. */
+ normalize_number(octstr_get_cstr(settings->unified_prefix), &phonenum);
+
+ if ((mmsc = settings->mms_resolvefuncs->mms_resolve(phonenum,
+ settings->mms_resolver_module_data,
+ settings, proxyrelays))) {
+ info(0, "mmsc for \"%s\" resolved to: \"%s\"",
+ octstr_get_cstr(phonenum), octstr_get_cstr(mmsc));
+
+ if (octstr_compare(mmsc, settings->hostname) == 0) {
+ if (settings->mms2mobile) { /* Send a copy to this VASP. */
+ Octstr *xerr = NULL;
+ int res = mms_sendtovasp(settings->mms2mobile,
+ e->from, to->rcpt,
+ e->msgId,
+ msg, &err);
+ info(0, "%s Global Queue MMS Send: Local Msg copy to VASP (%s) - "
+ "From %s, to %s, msgsize=%ld: err=%s",
+ SEND_ERROR_STR(res),
+ octstr_get_cstr(settings->mms2mobile->id),
+ octstr_get_cstr(e->from), octstr_get_cstr(to->rcpt), e->msize,
+ xerr ? octstr_get_cstr(xerr) : "(null)");
+ if (xerr)
+ octstr_destroy(xerr);
}
- }
- octstr_destroy(mmsc);
- } else /* Search VASP list, see what you can find... */
- for (j = 0, m = list_len(settings->vasp_list); j < m; j++)
- if ((vasp = list_get(settings->vasp_list, j)) != NULL &&
- _x_octstr_int_compare(vasp->short_code, phonenum) == 0) {
- res = mms_sendtovasp(vasp, e->from, to->rcpt,
- e->msgId,
- msg, &err);
+
+ res = mms_sendtomobile(e->from, to->rcpt,
+ e->subject, e->fromproxy,
+ e->msgId, e->expiryt, msg, e->dlr,
+ &err);
sent = 1;
- break;
- }
-
+ } else if (proxyrelays && list_len(proxyrelays) > 0) /* Step through proxies. */
+ for (j = 0, m = list_len(proxyrelays); jhost, mmsc)) {
+ res = mms_sendtoproxy(e->from, to->rcpt,
+ e->subject, mp->host,
+ e->msgId, e->expiryt, msg,
+ e->dlr, &err);
+ sent = 1;
+ break;
+ }
+ }
+ octstr_destroy(mmsc);
+ }
+ }
if (!sent) {
res = MMS_SEND_ERROR_FATAL;
err = octstr_format("MMSC error: Don't know how to deliver to %S !", to->rcpt);
-
+
}
if (phonenum) octstr_destroy(phonenum);
}
@@ -275,7 +278,7 @@ static int sendMsg(MmsEnvelope *e)
if (res == MMS_SEND_OK)
to->process = 0;
else { /* If there was a report request, queue it. */
-
+
if (e->dlr) {
Octstr *qfs;
MmsMsg *m = mms_deliveryreport(e->msgId, to->rcpt, tnow,