Re: it's frustrating

From: Date: Thu, 17 May 2001 16:00:24 +0000
Subject: Re: it's frustrating
References: 1 2 3 4  Groups: php.windows 
Request: Send a blank email to php-windows+get-7681@lists.php.net to get a copy of this message
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" <mkelley@nmsu.edu> schrieb im Newsbeitrag news:3B03E34E.6030000@nmsu.edu... > 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 <sascha@schumann.cx> > * Modified by Tobias Ratschiller <tobias@dnet.it>: > * - 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: foo@bar.com"; > $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("webmaster@mweller.de","", "", $message); > > ----------------------------------------------------------- > > > > > > > > > > ""Brian Paulson"" <webmaster@chieftain.com> schrieb im > > Newsbeitrag > > > > news:EPEKKECOPFJIPOEBDFAFIEIFCDAA.webmaster@chieftain.com... > > > >> 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 > mkelley@nmsu.edu > > 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: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.windows (#7681) next »