Send MMS from the Command Line

Posted by on Jul 17, 2007 in Support Blog

Topic Keywords: , , , ,

Last time, I posted a Windows JScript file that could be used to enable the sending of OMA Client Provisioning (XML Settings) documents from a command line interface.

Pretty cool?

Well, I thought so. But it is of somewhat limited usage to the average NowSMS customer, as the volume of OMA Client Provisioning messages being sent out via NowSMS is far less than messages of other types.

What would be really useful would be to expand upon the SMS Command Line interface example to allow the sending of MMS messages from a command line interface.

So I thought the ability to post an OMA Client Provisioning document via a command line interface was a good start toward the ultimate goal of a script that could post MMS message content from a command line interface.

But I was wrong. The issue was that an OMA Client Provisioning document is a text XML document. Windows JScript has great capabilities for processing text files, but binary files are another story, so it is more challenging to post an image (GIF/JPEG) to a server via JScript.

After quite a few frustrating attempts, I realised that while it might not be possible using JScript, it could be possible using VBScript instead.

Of course, I have zero VB or VBScript experience.

But I can surf the net to find examples that I can hack like the best of them.

To submit an MMS message to NowSMS, there are several different protocols that could be used: MM7 (XML HTTP POST), MM4 (SMTP based), MM1 (HTTP based), EAIF (MM1 with additional headers), or a proprietary URL submission technique. These options are described in greater detail at https://nowsms.com/doc/submitting-mms-messages.

I wanted to use the proprietary URL submission technique, because the encoding is a bit simpler. This is the interface that is used when you use the “Send MMS Message” web form in the NowSMS web interface. It uses “HTTP File Upload” or an HTTP POST of the “multipart/form-data” MIME type.

I found some great examples of how to perform “HTTP File Upload” submissions at http://www.motobit.com/tips/detpg_uploadvbsie/ … and I went about to learn enough VBScript to complete this script.

The resulting code is not pretty. (Is VBScript ever?) But, it is functional.

The result is sendmms.vbs. You can right-click on the file name to download and save this file.

Assuming that the script file is saved as a file named smsmms.vbs, you would issue the following command to send an MMS message:

cscript sendmms.vbs recipient[,recipient2,recipient3…] filename [filename2] [filename3…] [variable=setting]

recipient can contain either one recipient phone number, or a comma delimited list of recipients, e.g., +44777777777,+44777777778 (important – do not include spaces)

filename is the name of a local file to be included in the MMS message. Similar to when submitting an MMS message via the “Send MMS Message” web form, you may specify multiple files that NowSMS will package up as an MMS message. (Note: NowSMS identifies content types based on the file extension of the submitted file, see the MMSCTYPE.INI file for the default list of file extension to MIME type mappings.)

variable=setting can specify additional URL parameters supported by NowSMS, such as:

  • MMSSubject=SubjectLine
  • MMSFrom=SenderAddress
  • MMSDeliveryReport=Yes
  • MMSReadReport=Yes
  • MMSPriority=High Normal Low
  • MMSMessageClass=Personal Informational Advertisement
  • MMSForwardLock=Yes
  • DRMRestrict=Yes
  • DRMRestrictTextXML=Yes
  • DRMPermissionPlay=Yes
  • DRMPermissionDisplay=Yes
  • DRMPermissionExecute=Yes
  • DRMPermissionPrint=Yes
  • DRMConstraintCount=##
  • DRMConstraintStart=yyyy-mm-dd
  • DRMConstraintEnd=yyyy-mm-dd
  • DRMConstraintInterval=##

Note: If the Subject line contains a space character, put quotes around the setting, e.g., “MMSSubject=This is a test message”

Examples:

cscript sendmms.vbs +4477777777 image.gif filename.txt “MMSSubject=This is a test message”

cscript sendmms.vbs +4477777777,+4477777778 image.gif “MMSText=This is some message text” MMSFrom=+44777777779 MMSSubject=Test

cscript sendmms.vbs +4477777777 image.gif “MMSText=The content of this message has been forward locked” “MMSSubject=Forward Lock Test” MMSForwardLock=Yes

-bn

P.S. – If you want to send an Multimedia WAP Push instead of an MMS message, include a “variable=setting” parameter of MMSWAPPush=Yes

For comments and further discussion, please click here to visit the NowSMS Technical Forums (Discussion Board)...