About old msg on attachements using PHP mail function

From: Date: Fri, 21 Sep 2001 00:12:07 +0000
Subject: About old msg on attachements using PHP mail function
Groups: php.general 
Request: Send a blank email to php-general+get-68088@lists.php.net to get a copy of this message
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 (#68088) next »