How can I send an MMS via a GSM/GPRS modem connected to a linux computer?

Brian David picture Brian David · May 6, 2013 · Viewed 10.4k times · Source

I have a directory which contain say 50 image files (.jpg) each less than 300kb. This files should be attached as MMS and send from Linux computer using GSM/GPRS modem. I need to work out how to package a MMS and able to send it to a mobile phone or email from linux computer. Also please note that I want to be able to send the MMS message using my GSM/GPRS modem - NOT via clickatell or some other web service. I also do NOT want to be using a full blown MMSC gateway such as NowSMS (which is windows anyway) or MBuni. Please help me to find any Linux tool which can be worked through command line / any compile source code / any method which is easy to use.

Thanks in advance for your expertise

Answer

Burhan Khalid picture Burhan Khalid · May 6, 2013

Why do you want to do this? Its an overly complicated process and there is a reason there are MMSC gateways available. You only use the GPRS part to establish a PPP connection, then the rest of the stuff happens over IP.

I strongly suggest you use a gateway for this, and don't do this manually.

In order to establish the PPP connection:

  1. AT+CGDCONT? This should respond with the context you are on. This means you are ready to attach/connect.
  2. AT+CGATT=1 (attach your modem)
  3. AT+CGDATA=? (check what is the data mode)
  4. AT+CGACT=1 (activate your connection)

Now you are on PPP, and then you talk over the modem using whatever your provider is using. It could be anything from direct HTTP to MMSE protocol.

For example, here is a complete transcript over HTTP. First, we need to setup the modem and connection information. All these commands should get a response of OK from the modem.

AT+CMMSINIT # Initialize the MMS method
AT+CMMSCURL="some.url.com" # the MMS center URL
AT+CMMSCID=1 # Set bearer
AT+CMMSPROTO="1.1.1.1",8080 # MMS Proxy information
AT+SAPBR=3,1,"Contype","GPRS" # How you are sending
AT+SAPBR=3,1,"APN","foobar" # Set the APN
AT+SAPBR=1,1 # Activate the bearer context

Next, we prepare the message:

> AT+CMMSEDIT=1  # Enter edit mode
OK
> AT+CMMSDOWN="PIC",54321,30000 # Download a pic that is 54321 bytes
                                # and set the latency
                                # for the download to 30000 ms
CONNECT                         # This means, ready to receive data
                                # so send your file
OK                              # Data received
> AT+CMMSRECP="123456789"       # Set the recipient
OK
> AT+CMMSVIEW                   # View your message
(your message)
OK
> AT+CMMSSEND                   # Send the message
OK                              # Message sent
> AT+CMMSEDIT=0                 # Exit edit mode, and clear the buffer
OK

This of course, is specific to the modem that I was using. Your results may vary. I can tell you that this is an exercise in futility. Go with a proper provider if you want to actually send MMS messages.