Hi Dave:

On Tue, Jun 04, 2002 at 05:45:17PM -0400, Dave wrote:
> Email appears with text portion and attachment icon, but no attachment (Outlook
> 2000).

By "no attachment" I assume you mean you can't get the attachment through the user
interface.  But, I bet the attachment is there if you look at the source code of the
message itself.  Right?  That indicates the attachment was sent and received.  The 
trick is then getting Lookout to properly allow you to save the attachment.

One thought, someone told me of a seting in Internet Explorer:

* On the menu bar click on Tools, then Options, then choose the tab Security.
* There is a check box for "Do not allow attachments to be saved or opened
* that could potentially be a virus".

Now, regarding your code, let's see if we can find something that could be the 
problem.  I'm going to touch on things that aren't the problem and things that could 
be the problem w/o distinction...

> if \n is replaced with \r\n then no attachment flag appears, otherwise same
> problem

\r\n is the line break protocol specified by RFC 822.  I suggest using it.

> # $from, $to, $body, and $attachment are provided in the previous form

> $sig = "\n--\nWebsite Mailer\n";
> $body .= $sig;

Why assign that string to $sig, then assign it to $body only to assign IT to $str.  
Just add the string directly to $str further down in your script.

> $headers = "From: $from\n";
> $boundary = "=====WSM." . md5(uniqid(time())) . "=====";

Add an underscore "_" to the end of the boundary.

> $headers .= "MIME-Version: 1.0\n";
> $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"$boundary\"\n\n";

Trailing line breaks aren't necessary.  Also, take out the line breaks and tabs in 
the middle of the lines just to make sure that's not mucking up things.

> $str = "--$boundary\n";
> $str .= "Content-Type: text/plain;\n\tcharset=\"us-ascii\"\n";
> $str .= "Content-Transfer-Encoding: 7bit\n\n";
> $str .= "$body\n\n";

> $fp = fopen($attachment, "rb");
> $data = fread($fp, filesize($attachment));
> $data = chunk_split(base64_encode($data),76,"\n");
> fclose($fp);

Doing the following is simpler than the previous four lines...
   $data = chunk_split( base64_encode( implode('', file($attachment) ) ) );

Better yet, forget about this step of assigning it to $data here.  Just add it 
directly to the $str variable below via a 
   $str .= chunk_split( ..... you get the idea ....

Do note, I think one of my email programs is experiencing some sort of corruption
with the chunk_split() and/or base64_encode().  This may be your problem.  I haven't
had time to isolate it though, so can't explain further.

> $str .= "--$boundary\n";
> $str .= "Content-Type: ".$attachment_type.";\n\tname=\"".$attachment_name .
> "\"\n";
> $str .= "Content-Transfer-Encoding: base64\n";
> $str .= "Content-Disposition: attachment; \n\tfilename=\"".$attachment_name .
> "\"\n\n";
> $str .= $data;
> $str .= "--$boundary--\n";
> $body = $str;

Again, don't waste memory and time reassigning things.  Delete that last line.  Just
put $str in the mail()  function.  Or, if you want, rename $str to $body.

> if(mail($to, $subject, $body, $headers)){
>       $status.='<br>Successfully sent.';
> }else{
>       $status.='<br>An error occurred while sending.';
> }

Well, that's everything I can think of.  Let us know what happens.



               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to