Posted by Stefan Rybacki on 09/21/05 12:09
ralphNOSPAM@primemail.com wrote:
> I'm trying to write a php script to send a .jpg image to my MMS cell
> phone but need some help. I can get the MMS message to arrive at my
> phone but when I open up the message there is no image - it's empty!!
>
> Here is my code:
>
> $boundary = '----=' . md5( uniqid ( rand() ) );
> $theFile = "radar.jpg";
> $message .= "Content-Type: image/pjpeg; name=\"$theFile\"\n";
> $message .= "Content-Transfer-Encoding: base64\n";
> $message .= "Content-Disposition: inline; filename=\"$theFile\"\n\n";
>
> $path = "/home/public_html/radar.jpg";
> $fp = fopen($path, 'r');
> do //we loop until there is no data left
> {
> $data = fread($fp, 1024);
> if (strlen($data) == 0) break;
> $content .= $data;
> } while (true);
>
> $content_encode = chunk_split(base64_encode($content));
> $message .= $content_encode . "\n";
> $message .= "--" . $boundary . "\n";
>
> $headers = "From: cellphone@mydomain.com\n";
> $headers .= "MIME-Version: 1.0\n";
> $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
> mail($myMMSaddress, "MMS Image Test", $message, $headers);
>
I guess you don't send a MMS you are sending an email. That is different.
BTW: for MMS messages have a look here:
http://www.openmobilealliance.org/release_program/docs/CopyrightClick.asp?pck=MMS&file=V1_2-20050429-A/OMA-MMS-ENC-V1_2-20050301-A.pdf
To your problem with sending emails with attachments:
- try to send this email to your normal email application like Thunderbird and have a look
whether it works there or not
- remember you have to close the last attachment with --$boundary-- not just --$boundary
Regards
Stefan
[Back to original message]
|