Receive MMS with modem and Java

Receive MMS with modem and Java SearchSearch
Author Message
Yopie Maulana
New member
Username: Y0p4y

Post Number: 1
Registered: 06-2012
Posted on Wednesday, June 06, 2012 - 08:05 am:   

Hi,,i have same problem with FRVeau..
Can you help me???
I have tried to send MMS with java and succesfull, but i cant receive MMS with modem..could you give me java source code to receive MMS???????
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3986
Registered: 08-2008
Posted on Wednesday, June 06, 2012 - 04:00 pm:   

Hi Yopie,

I have moved your question to a new discussion thread, because I do not believe it is related to the question in The questions in that thread are referring to mobile originated MMS sent from phone to phone with NowSMS as the MMSC Server.

In your configuration, NowSMS is operating as an MMS client, sending and receiving MMS messages via the mobile operator MMSC.

Unfortunately, I do not have any Java examples, but I can give you some suggestions and additional information.

First, make sure your modem is capable of receiving MMS messages. If it is a dedicated modem device, you should be ok. If it is a phone acting as a modem, the MMS client on the phone will intercept the message, and it will not be received over the modem.

By default, when NowSMS receives an MMS message, it will parse the message content and store it using a file-based interface in the MMS-IN directory.

Also, when an MMS message is received, the stat counter for "SMS Received" should increase (usually by 2, but sometimes only by 1).

So before going any further, make sure that NowSMS is receiving MMS messages (for more info, see sing-a-gprs-modem).

I will add another post shortly with more detail on how you can then process those received MMS messages from your application.

NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3987
Registered: 08-2008
Posted on Wednesday, June 06, 2012 - 05:08 pm:   

With that introductory information out of the way, there are three different ways that NowSMS can deliver received MMS messages to your application.

1.) A file-based/directory interface where newly received MMS messages are placed in a directory on the NowSMS server. A header file contains a text version of the header of the MMS message, as well as pointers to separate files that contain the MMS message content (text, images, video, etc.). Your application can either scan that directory for new messages, or NowSMS can spawn a command line application each time a new MMS message is received.

2.) NowSMS reformats the received MMS message as an HTTP file upload and performs an HTTP POST to deliver the received message content to your application using the same interface as is used to upload files from an HTML form in a web browser. We have a PHP example that shows how to process the received MMS message. From a Java Servlet, you would use ServletFileUpload to process the received MMS message.

(Alternatively there is also an XML/SOAP interface over HTTP POST where the MMS message content is packaged according to the MM7 format defined by the 3GPP. For most developers, this is more complicated to work with than the HTTP File Upload format.)

3.) The MMS message content is converted to an e-mail format and delivered to an e-mail address. Your application scans the e-mailbox for new messages.


The default configuration is the file-based/directory interface. In this case, what happens is that received messages get written to the MMS-IN subdirectory of NowSMS.

The format is that there is a text file that has the MMS message headers in text format. This file has an extension of ".hdr". An example of the format is shown at the following link: iles

(The format that we convert these messages to is compatible with the format that is input to MMSCOMP.)

Each of the message components (including any text components) are written to a separate file. They are referenced by an "X-NowMMS-Content-Location: filename" header (one for each component). "filename" is relative to the directory in which the ".hdr" file exists. Generally, NowSMS creates a separate directory to hold these content files for each of the content files, here's an old example that I copied from another thread:

In this case, the filename in the MMS-IN directory is 3F287A4A.hdr:

Message-type: m-retrieve-conf
Transaction-id: 3F287A46
MMS-version: 1.0
From: +44xxxxxxxxxx/TYPE=PLMN
To: +44xxxxxxxxxx/TYPE=PLMN
Date: Mon, 20 Dec 2003 20:28:37 GMT
Message-class: Personal
Message-size: 20796
Subject: Test MMS
Content-type: application/vnd.wap.multipart.related; start=<testmms.smil>; type=application/smil
X-NowMMS-Content-Location: 3F287A4A\testmms.smil;application/smil;charset=utf-8
X-NowMMS-Content-Location: 3F287A4A\testlogo.gif;image/gif
X-NowMMS-Content-Location: 3F287A4A\catchy_g.amr;audio/amr
X-NowMMS-Content-Location: 3F287A4A\testmms.txt;text/plain;charset=utf-8

In this case, the X-NowMMS-Content-Location header includes a directory name in the file path, and that means that the file is in that named subdirectory beneath the MMS-IN subdirectory. (NowSMS creates a subdirectory name that matches the ".hdr" file without the extension, so after processing the ".hdr" file, delete the corresponding directory.)

You can either scan the MMS-IN directory from your application, or there is also a configuration option where NowSMS can run a command every time it places a new MMS message in the MMS-IN directory:

To define a callback to be triggered every time an MMS message is received to the MMS-IN directory. Under the [SMSGW] header, add ReceiveMMSCallback=xxxxxx, where xxxxxx is a local executable command or an HTTP URL. A replaceable variable named @@Filename@@ can be included to specify the name of the header file (without path) for the received MMS message.

For example:

ReceiveMMSCallback=c:\windows\system32\cscript.exe c:\scripts\receivemms.js @@Filename@@

When 3F287A4A.hdr is created, the following command would be run:

c:\windows\system32\cscript.exe c:\scripts\receivemms.js 3F287A4A.hdr

(This example is spawning a simple Windows JScript under the Windows JScript command line processor, but the same approach could be used to spawn the Java command line processor.)


This technique uses HTTP POST to transmit the received MMS message content to a script file running on another web server. The HTTP POST format that is used is the same format that is used for “HTTP File Upload” (multipart/form-data) from an HTML form with a web browser.

When an MMS message is received, NowSMS can be configured to perform an HTTP File Upload Post to a configurable URL.

We've posted a PHP example here: ript

Working from a Java Servlet, you would process the HTTP file upload posting using ServletFileUpload, which is described in more detail at

The form fields (or variables) contain the MMS message content:

The “PhoneNumber” variable contains the message recipient phone number (usually the phone number associated with the GSM/GPRS modem if messages are being received over a modem interface).

The “MMSFrom” variable contains the message sender address.

The “MMSSubject” variable contains the subject of the MMS message.

The “MMSFile[]” variable contains the raw file content of individual objects within the MMS message, and may be repeated multiple times for each piece of content in the MMS message (e.g., text, image, video). You would check the content type of each of these objects to determine how to process the content.

Even if you're not using PHP, I'd recommend looking at ript for more information on configuring this.


If you're familiar with e-mail concepts, and have used libraries for parsing and processing e-mail messages before, this relatively straight-forward. Otherwise, I'd stick to one of the other options.

NowSMS Support
Yopie Maulana
New member
Username: Y0p4y

Post Number: 2
Registered: 06-2012
Posted on Thursday, June 07, 2012 - 05:03 am:   

thank u so much for your answer...
I was successful send MMS from NowSMS to handphone with java source code.(
a MMS who sent by NowSMS was received by handphone in inbox.
I have question. what the specific port, so i can receive MMS in J2ME application????
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 3989
Registered: 08-2008
Posted on Thursday, June 07, 2012 - 04:04 pm:   

This should help you: