Sab: Bilder via Mail versenden!

Beitrag lesen

Guten Abend,

hab mal eine Frage. Warum geht das Script bei mir nicht was Ihr gleich sehen werdet. Es versendet zwar was aber nicht das Bild, das gerade angesehen wird?

Hier mal das Formular:

<th scope="col"><form name="form2" method="post" action="sendpic.php">
    <table width="100%" align="left" cellpadding="0" cellspacing="0">
      <tbody>
        <tr> </tr>
      </tbody>
      <tbody>
        <tr>
          <td colspan="2" height="12"><img src="../img/navigation/info.jpg" height="12" width="128"></td>
        </tr>
      </tbody>
      <tbody>
        <tr>
          <td width="1" background="../img/navigation/pixel.jpg" bgcolor="#A00608"><img src="../img/navigation/fake.gif" height="1" width="1"></td>
          <td width="301" valign="top">
            <table width="100%" height="10" border="0" cellpadding="4" cellspacing="2">
              <tbody>
                <tr>
                  <td width="31%"><p><strong>Empf&auml;nger</strong>:</p></td>
                  <td width="38%"><input name="mailto" id="kommentar22" size="25" class="chatfields" type="text"></td>
                  <td width="31%"><input name="sendmail" type="submit" class="chatfields" id="go23" value="Mail">
      <input type="hidden" name="bildid" value="<?php echo $idx_bild; ?>">
                    </td>
                </tr>
                <tr valign="middle">
                  <td height="33">
                    <p><strong>Nachricht:</strong></p></td>
                  <td height="33" colspan="2"><textarea name="message" cols="37" rows="6" wrap="VIRTUAL" class="chatfields" id="textarea2"></textarea></td>
                </tr>
              </tbody>
          </table></td>
          <td width="4">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2" background="../img/navigation/pixel.jpg" bgcolor="#A00608" height="1"><img src="../img/navigation/fake.gif" height="1" width="1"></td>
        </tr>
      </tbody>
    </table>
  </form></th>

So hier kommt mal das PHP Script zum versenden der Nachricht:

$fromaddress="";
//if ((isset($_POST['sendmail'])) && (!empty($_POST['mailto'])) && (!empty($_POST['message'])) && (isset($_POST['bildid'])))
//    {
        $bilder=mysql_query("select * from bilder where id='".$_POST['bildid']."'");
        $bild=mysql_fetch_assoc($bilder);
        $message=imap_8bit($_POST['message']);
        $message.="\n\n";
        $message.="\t".imap_8bit("<<".$bild['bild'].">>");
        $boundary="----".md5(uniqid());
        $email="";
        $email.="Content-class: urn:content-classes:message";
        $email.="\nUser-Agent: Bildmailer";
        $email.="\nMIME-Version: 1.0";
        $email.="\nContent-Type: multipart/mixed;\n\tboundary="".$boundary.""";
        $email.="\nFrom: ".$fromaddress;
        $email.="\nX-Priority: 3 (Normal)";
        $email.="\nImportance: Normal";
        $email.="\n\n--".$boundary;
        $email.="\nContent-Type: text/plain;\n\tcharset="iso-8859-1"";
        $email.="\nContent-Transfer-Encoding: quotet-printable";
        $email.="\n\n".$message;
        $email.="\n\n--".$boundary;
        $file=fopen("bilder/".$bild['bild'],"r");
        $content=fread($file,filesize("bilder/".$bild['bild']));
        fclose($file);
        $encodedfile=chunk_split(base64_encode($content));
        $email.="\nContent-Type: application/octet-stream;\n\tname="".$bild['bild'].""";
        $email.="\nContent-Transfer-Encoding: base64";
        $email.="\nContent-Description: ".$bild['dateiname'];
        $email.="\nContent-Disposition: attachment;\n\tfilename="".$bild['bild'].""";
        $email.="\n\n".$encodedfile."\n\n--".$boundary;
        $email.="--";
        imap_mail($_POST['mailto'],"Bild","",$email);
        echo "Mail wurde verschickt";
//    }
?>

Gruß Sab