$val) { $ds =sprintf("%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n%s\r\n",$bo,$key,$val); $dc += mb_strlen($ds,'8bit'); } $dc += mb_strlen($bo,'8bit')+3; fputs($fp, "Content-length: $dc\r\n"); fputs($fp, "\r\n"); fputs($fp, $mimeFiller); foreach($data_to_send as $key=>$val) { $ds =sprintf("%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n%s\r\n",$bo,$key,$val); fputs($fp, $ds ); } $ds = $bo."--\r\n" ; fputs($fp, $ds); $res = ""; while(!feof($fp)) { $res .= fread($fp,1); } fclose($fp); return $res; } /* Add a file part to the multipart data */ function MmsAddFile ($data, $file, $contenttype) { $fa = @file($file); $xf ="Content-Type: ".$contenttype."\r\n\r\n".implode("",$fa); $data["MMSFile\"; filename=\"$file"] = $xf; return $data; } /* Add a field to the multipart data */ function MmsAddField ($data, $fieldname, $fieldvalue) { $data[$fieldname] = "\r\n" . $fieldvalue; return $data; } /* Initialise the MMS message */ function MmsInit () { $data = ""; return $data; } /* Set parameters for connecting to the NowSMS server */ $nowsmsHostName = "127.0.0.1"; /* IP Address or host name of NowSMS Server */ $nowsmsHostPort = "8800"; /* NowSMS Port number for the web interface */ $nowsmsUsername = "test"; /* "SMS Users" account name */ $nowsmsPassword = "test"; /* "SMS Users" account password /* Initialise the MMS Message structure */ $mmsMessage = MmsInit(); /* Set MMS message fields */ /* "PhoneNumber" is the recipient, and can be a comma deilmited list of recipients or the name of a NowSMS distribution list */ /* "MMSFrom" is the sender */ /* "MMSSubject" is the subject */ /* "MMSText" is an optional text part of the message. Text parts can also be added as file references */ /* For additional parameters, please see http://blog.nowsms.com/search/label/sendmms.php */ $mmsMessage = MmsAddField ($mmsMessage, "PhoneNumber", "+4477777777777"); $mmsMessage = MmsAddField ($mmsMessage, "MMSFrom", "sender@domain.com"); $mmsMessage = MmsAddField ($mmsMessage, "MMSSubject", "Subject of Message"); /* The MMSText field is optional */ $mmsMessage = MmsAddField ($mmsMessage, "MMSText", "Hello!"); /* Add the file parts here, referencing local files. Specify a path to the file, remembering to escape backslashes in the path (c:\temp\file becomes c:\\temp\\file). The last parameter is the MIME content type, e.g., "image/gif", "image/jpeg", "image/png", "text/plain" or "application/smil" ... however, note that current versions of NowSMS ignore the MIME content type when messages are submitted via the interface used by this PHP script. Instead, NowSMS uses the file extension to determine the content type (e.g., ".gif", ".jpg", ".png", ".txt", ".smil" */ $mmsMessage = MmsAddFile ($mmsMessage, "f:\\temp\\file.gif", "image/gif"); /* Now send the message. The HTTP response from the server is returned by this function, and this example echoes it to the console. */ $x = MmsSend ($nowsmsHostName, $nowsmsHostPort, $nowsmsUsername, $nowsmsPassword, $mmsMessage); echo $x; ?>