*HELP- whats wrong? SENDS PICTURE TO PHONE

Discussion in 'PHP' started by donthate, Dec 29, 2006.

  1. #1
    The code is below, it gets it and send the textmessage to my phone but only shows the image name, not the real image, yes i can receive/send/download images on my phone:

    <?php
    include("global.inc.php");
    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    pt_register('POST','IP');
    pt_register('POST','date');
    pt_register('POST','CellNumber');
    $Ringtone=$HTTP_POST_FILES['Ringtone'];
    if($HTTP_POST_FILES['Ringtone']['tmp_name']==""){ }
     else if(!is_uploaded_file($HTTP_POST_FILES['Ringtone']['tmp_name'])){
    $error.="<li>The file, ".$HTTP_POST_FILES['Ringtone']['name'].", was not uploaded!";
    $errors=1;
    }
    $IP = $HTTP_SERVER_VARS["REMOTE_ADDR"];
    $date = date("l jS of F Y h:i:s A");
    if($errors==1) echo $error;
    else{
    $image_part = date("h_i_s")."_".$HTTP_POST_FILES['Ringtone']['name'];
    $image_list[3] = $image_part;
    copy($HTTP_POST_FILES['Ringtone']['tmp_name'], "files/".$image_part);
    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
    $fileatt = "/home/ffilehos/public_html/insanetext/ringtone/ban1.jpg"; // Path to the file                  
    $fileatt_type = "image/jpeg"; // File Type  
    $fileatt_name = "ban1.jpg"; // Filename that will be used for the file as the attachment  
    
    $email_from = "mailer@insanetext.com"; // Who the email is from  
    $email_subject = "harrow"; // The Subject of the email  
    $email_txt = "harrrrow!"; // Message that the email has in it  
    
    $email_to = "$CellNumber@teleflip.com"; // Who the email is too  
    
    $headers = "From: ".$email_from;  
    
    $file = fopen($fileatt,'rb');  
    $data = fread($file,filesize($fileatt));  
    fclose($file);  
    
    $semi_rand = md5(time());  
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  
        
    $headers .= "\nMIME-Version: 1.0\n" .  
                "Content-Type: multipart/mixed;\n" .  
                " boundary=\"{$mime_boundary}\"";  
    
    $email_message .= "This is a multi-part message in MIME format.\n\n" .  
                    "--{$mime_boundary}\n" .  
                    "Content-Type:text/html; charset=\"iso-8859-1\"\n" .  
                   "Content-Transfer-Encoding: 7bit\n\n" .  
    $email_message . "\n\n";  
    
    $data = chunk_split(base64_encode($data));  
    
    $email_message .= "--{$mime_boundary}\n" .  
                      "Content-Type: {$fileatt_type};\n" .  
                      " name=\"{$fileatt_name}\"\n" .  
                      //"Content-Disposition: attachment;\n" .  
                      //" filename=\"{$fileatt_name}\"\n" .  
                      "Content-Transfer-Encoding: base64\n\n" .  
                     $data . "\n\n" .  
                      "--{$mime_boundary}--\n";  
    
    $ok = @mail($email_to, $email_subject, $email_message, $headers);  
    
    if($ok) {  
    echo "<font face=verdana size=2>The file was successfully sent!</font>";  
    } else {  
    die("Sorry but the email could not be sent. Please go back and try again!");  
    }  
    $link = mysql_connect("localhost","ffilehos_txt","kidrock");
    mysql_select_db("ffilehos_txt",$link);
    $query="insert into rlog (IP,date,Cell_Number,Ringtone) values ('".$IP."','".$date."','".$CellNumber."','".$where_form_is."files/".$image_list[3]."')";
    mysql_query($query);
    ?>
    
    
    <!-- This is the content of the Thank you page, be careful while changing it -->
    
    <h2>Thank you!</h2>
    
    <table width=50%>
    Ringtone sent to: <?php echo $CellNumber; ?><br>
    Please give the system a couple minutes to send it!<br>
    </table>
    
    
    <?php 
    }
    ?>
    
    
    
    
    
    
    
    
    
    
    
    
    Code (markup):

     
    donthate, Dec 29, 2006 IP
  2. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try sending an e-mail to your phone with an image using hotmail,gmail or whatever e-mail client you normally use. If it works then great. If not, then this just isn't going to work for you.

    Then send that same message to your normal inbox. Check the message source and check your code against it.

    I'd also recommend not writing your own SMTP client and using PHPMailer instead. It's a very powerful SMTP class.

    You should also have your script e-mail your normal e-mail address and see if your e-mail client gets the attachment properly. If hotmail,gmail, whatever can't read your message then your phone definitly won't.
     
    KalvinB, Dec 30, 2006 IP
  3. GeorgeB.

    GeorgeB. Notable Member

    Messages:
    5,695
    Likes Received:
    288
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Agreed. There are plenty SMTP classes out there that are tried and tested in production environments.

    SwiftMailer saved my life and it powers my www.onlyriddles.com automated daily riddles feature. :)
     
    GeorgeB., Dec 31, 2006 IP