Thank you Michael,

it isn't working with images larger then 3kB.
I start to belive Windows is making the trouble. Who knows why.
Meanwhile I tried a lot of different mail classes, wrote my own code but
nothing works.


Markus


"Michael Kelley" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I found this on PHP.net It works when you hardcode the values (where I
> have the value arrows.gif). I've been playing with it trying to modify
> it to do an upload and sending of an email with any kind of attachment.
>
> <?
>
> /*
>   *  Class mime_mail
>   *  Original implementation by Sascha Schumann <[EMAIL PROTECTED]>
>   *  Modified by Tobias Ratschiller <[EMAIL PROTECTED]>:
>   *      - General code clean-up
>   *      - separate body- and from-property
>   *      - killed some mostly un-necessary stuff
>   */
>
> class mime_mail
>   {
>   var $parts;
>   var $to;
>   var $from;
>   var $headers;
>   var $subject;
>   var $body;
>
>    /*
>    *     void mime_mail()
>    *     class constructor
>    */
>   function mime_mail()
>    {
>    $this->parts = array();
>    $this->to =  "";
>    $this->from =  "";
>    $this->subject =  "";
>    $this->body =  "";
>    $this->headers =  "";
>    }
>
>    /*
>    *     void add_attachment(string message, [string name], [string
ctype])
>    *     Add an attachment to the mail object
>    */
>   function add_attachment($message, $name =  "", $ctype =
> "application/octet-stream")
>    {
>    $this->parts[] = array (
>                             "ctype" => $ctype,
>                             "message" => $message,
>                             "encode" => $encode,
>                             "name" => $name
>                            );
>    }
>
> /*
>   *      void build_message(array part=
>   *      Build message parts of an multipart mail
>   */
> function build_message($part)
>   {
>   $message = $part[ "message"];
>   $message = chunk_split(base64_encode($message));
>   $encoding =  "base64";
>   return  "Content-Type: ".$part[ "ctype"].
>                          ($part[ "name"]? "; name = \"".$part[ "name"].
> "\"" :  "").
>                           "\nContent-Transfer-Encoding:
> $encoding\n\n$message\n";
>   }
>
> /*
>   *      void build_multipart()
>   *      Build a multipart mail
>   */
> function build_multipart()
>   {
>   $boundary =  "b".md5(uniqid(time()));
>   $multipart =  "Content-Type: multipart/mixed; boundary =
> $boundary\n\nThis is a MIME encoded message.\n\n--$boundary";
>
>   for($i = sizeof($this->parts)-1; $i >= 0; $i--)
>      {
>      $multipart .=  "\n".$this->build_message($this->parts[$i]).
> "--$boundary";
>      }
>   return $multipart.=  "--\n";
>   }
>
> /*
>   *      void send()
>   *      Send the mail (last class-function to be called)
>   */
> function send()
>   {
>   $mime =  "";
>   if (!empty($this->from))
>      $mime .=  "From: ".$this->from. "\n";
>   if (!empty($this->headers))
>      $mime .= $this->headers. "\n";
>
>   if (!empty($this->body))
>      $this->add_attachment($this->body,  "",  "text/plain");
>   $mime .=  "MIME-Version: 1.0\n".$this->build_multipart();
>   mail($this->to, $this->subject,  "", $mime);
>   }
> };  // end of class
>
> /*
>   * Example usage
>   */
>
>   $attachment = fread(fopen("arrows.gif", "r"), filesize("arrows.gif"));
>
>   $mail = new mime_mail();
>   $mail->from = "someone";
>   $mail->headers = "Errors-To: [EMAIL PROTECTED]";
>   $mail->to = "someone else";
>   $mail->subject = "Testing...";
>   $mail->body = "This is just a test";
>   $mail->add_attachment("$attachment", "arrows.gif", "image/gif");
>   $mail->send();
>
>
> ?>
>
>
>
> M. Weller wrote:
>
> > Thanks Brian for your fast respond.
> >
> > I tried but still the same:  it doesn't work.
> >
> > I used the following code:
> > -----------------------------------------------------------
> > $filename = 'background.gif';
> > $myimage = fread($fp = fopen($filename, 'r'), filesize($filename));
> > fclose($fp);
> >
> > $content = chunk_split ( base64_encode ( $myimage ) );
> > $boundary = 'NEXT_PART';
> > $message= "Content-Type: multipart/mixed; boundary='$boundary'\n";
> > $message.= "Mime-Version: 1.0\n";
> >
> > then in the message:
> >
> > $message.= "--$boundary\n";
> > $message.= "Content-Type: image/gif; name='my_image.gif'\n";
> > $message.= "Content-Transfer-Encoding: base64\n";
> > $message.= "Content-Disposition: attachment\n\n";
> >
> > $message = $content;     // here I used $message .= $content;
> >
> > mail("[EMAIL PROTECTED]","", "", $message);
> > -----------------------------------------------------------
> >
> >
> >
> >
> > ""Brian Paulson"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> >
> >> Are you trying to attach it or put the image in the body of the
message?
> >>
> >> If you  are trying to attach it try looking at this message from the
> >> archives
> >>
> >> http://marc.theaimsgroup.com/?l=php-general&m=99003506223055&w=2
> >>
> >> Thank You
> >> Brian Paulson
> >> Sr. Web Developer
> >> The Pueblo Chieftain
> >> www.chieftain.com
> >> 1-800-279-6397
> >>
>
>
> --
>
> Michael Kelley
> [EMAIL PROTECTED]
>
> Programmer/Systems Analyst I
> New Mexico State University
> Information and Communication Technologies
> Work # (505)-646-1374
> P.O. Box 30001
> MSC: 3AT
> Las Cruces, NM 88003
>
>
>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to