Re: About old msg on attachements using PHP mail function

From: Date: Sat, 22 Sep 2001 03:49:17 +0000
Subject: Re: About old msg on attachements using PHP mail function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-68264@lists.php.net to get a copy of this message
I believe you will need to stuff the body into the mime-headers like another attachment and have the body be empty... Even that *may* not work... Another option is to bypass the mail() function entirely and just fsockopen to port 25 and fread/fwrite the right stuff to talk to SMTP. It ain't rocket science -- I've even managed to do it for regular mail in higher volume than mail() can handle. Disclaimer: I'd find it easier to snag somebody else's attachment class, and I hate classes in PHP... You could just look at their source and see how they do it. -- WARNING richard@zend.com address is an endangered species -- Use ceo@l-i-e.com Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: M <mavemus@yahoo.com.br> Newsgroups: php.general To: <php-general@lists.php.net> Sent: Thursday, September 20, 2001 7:12 PM Subject: About old msg on attachements using PHP mail function > Hello, regarding old email from pylem@sympatico.ca about mail > attachements > > From: py" <pylem@sympatico.ca> 21/05/01 08:25 > Subject: Re: [PHP] sending attachements with mail > To: "Tolga \"thorr\" Orhon" <thorr@asenacorp.com> > CC: <php-general@lists.php.net> > > Here is a nice class that handles e-mail attachment. > Works fine for me. > > .... > > function write_mimeheaders($filename, $mime_filename) { > if ($mime_filename) $filename = $mime_filename; > $out = "MIME-version: 1.0\n"; > $out = $out . "Content-type: multipart/mixed; "; > $out = $out . "boundary=\"$this->mime_boundary\"\n"; > $out = $out . "Content-transfer-encoding: 7BIT\n"; > $out = $out . "X-attachments: $filename;\n\n"; > return $out; > } > > function write_smtpheaders($addr_from) { > $out = "From: $addr_from\n"; > $out = $out . "Reply-To: $addr_from\n"; > $out = $out . "X-Mailer: PHP3\n"; > $out = $out . "X-Sender: $addr_from\n"; > return $out; > } > > ....... > > I am trying to attach single text file to mail, then don't want to > implement new class for this task. > I imagine to send MIME messages, it would be enough build appropriate > headers, in same way PY wrote these functions above, then send these > headers into PHP mail function. > > PHP mail function has parameters ($TO,$SUBJECT,$BODY,$HEADERS) , then I > built MIME headers into $HEADERS parameter. Message arrives ok to me, > headers are right placed into message headers, but no attachements > appears for me (and no body also!) > My doubt is: when sending MIME parts, should $BODY be empty (and actual > body sent like MIME part), or rather should I mount all my headers into > $BODY and let $HEADERS empty? > > What I made is: > > $mime = 'From: xxx@xxxxxx.com\n'; > $mime = $mime . 'MIME-version: 1.0\n'; > $mime = $mime . 'Content-type: multipart/mixed\n'; > $mime = $mime . 'Boundary="1234567890"\n'; > $mime = $mime . '--1234567890'; > $mime = $mime . 'Content-type: text/plain; name="myfile.txt";'; > $mime = $mime . 'this is my text file to be attached, blha blha > blha...'; > > mail(receiver@xxx.com,"mysubject","mybody",$mime) > > mail arrives ok, but no body and no attachement into. > > Thanks in advance. > > Miguel > >

« previous php.general (#68264) next »