Miniware logo
Articles / Create your own mms server (mmsc)

Create your own mms server (mmsc)

This article describes how to crate a mms server (mmsc) using an ordinary pc, apache web server and php.

To begin with, I should first say what is a mms server and why somebody would like to implement one. When somebody sends a mms message from his mobile phone to another phone what actually happens is that the mobile phone post the message to a mms server (called mmsc), then mmsc sends a notification to the recipient of the mms message and the recipient downloads the message from the mms server. Actually you can see the mms server you are using by checking mms settings. In my nokia it is under messages-> settings-> multimedia messages-> active connection settings-> home page. All the traffic is done through gprs. So why someone would like to to implement his own mms server? The reason I did it is to allow my friends to send me mms with 1/3 of the cost of a regular mms! As I already said, mms is send using gprs, a mms is usually around 30kb (containing an image), now calculate how much it costs to send 30kb using gprs and how much it costs to send a mms. Another reason is to back up you mms into your computer.

The mobile phone is sending the mms to the web server using HTTP POST, then the web server sends back an acknowledgement. The acknowledgement says that "I receive mms with transaction id X". So all you need is a php page to handle the posted data and to send back an acknowledgement. So here is the code for the php page:

<?php
//the page that is returned back is not a html page but
//a mms message.So we must set the proper mime type

header("Content-Type: application/vnd.wap.mms-message");
//a mms message doesn't containt the sender number so it has
//to be found by another way. The way I am using here is
//by passing it form the url using ?n=7878.....

$sender = $_GET['n'];
//this variable stores the current date and time
$cdate = date(dmyHis);
//I am creating a variable that is going to be used in file name
//so to avoid dublicate names

$serial = 0;
//trying to crate a name that is not used
$fname = $sender."_".$cdate.$serial.".mms";
while(file_exists("mms/".$fname)){//if the name is used increment the
   $serial = $serial +1;          //serial by 1
   $fname = $sender."_".$cdate.$serial.".mms";
}
//The right name has been found! so lets creat a file
$mms = fopen("mms/".$fname, "w");
//The mms message is in the POST data so the only thing we have to do
//is to store the post data to a file

fwrite($mms, $HTTP_RAW_POST_DATA);

//send response
print(chr(0x8c));
print(chr(0x81));
print(chr(0x98));
//the above hexadecimals mean that the mms has been received
//we have to send then the transaction id. The transaction id
//starts always in the 3rd byte of the mms message and it ends
//with 0. so we read fron the 3rd byte until we find 0

$x = 3;
while(substr($HTTP_RAW_POST_DATA,$x,1)!=0){
  print(substr($HTTP_RAW_POST_DATA,$x,1));
  $x++;
}
//some additional hexadecimals needed
print(chr(0));
print(chr(0x8D));
print(chr(0x90));
print(chr(0x92));
print(chr(128));

?>

The comments in code explain what each part is doing.

Now you have a php page. Put it in your web site folder. Suppose your web site url is http://www.mymmsc.com and you have named your php file mms.php Go to the mms settings of your phone and change the home page to be http://www.mymmsc.com/mms.php?n=your_phonenumber

After that send a mms. As recipient put whatever as your mms won't leave the mmsc. When the mms is send in the folder where mms.php resides you will notice that a folder mms has been created and a mms file will be inside. You don't really have a lot of options to view the mms file. One way is by using the nokia internet toolkit which can be found in Nokia Forum. Another way is to use mms  parser that I has created which can be found here.

A number of documents  are following which help you to understand the philosophy of mms. To access the documents click here

Moreover you can find a lot of information in the forum of nowsms.com

The content of this page can be reproduced as long as the author and the source are mentioned. For questions please use the forum. Nikos Fotiou
Comments
(Post new comment)

2006-09-07 13:11:31 Michael wrote:
I tried using this with no luck. Im trying with a ppc phone and have to enter a port, and gateway. Its using wap2.0, any help would be appreciated. I can be contacted at lvballer06 at yahoo. Thanks.


2006-05-30 23:45:07 Kenn wrote:
Hi, I had found your website very, very interesting. I am after a spec. that will tell me exactly the format of the MMS file. For example: when sending the MMS eventually a request is made to download the MMS file from the webserver. I have been looking for weeks to tell me how the MMS file should be encoded without no luck (I need the exact spec. link). Would you know what this is? I would appreciate any help that you could provide in this. The email is (edited) Much appreciated.