Re: [PHP] Re: [PHP Attachement Problems - MAC ISSUE!!

2004-10-06 Thread PHP Junkie
Ave,

One more thing I'd like to point out, which I just discovered. The php code
I was using earlier, prior to using Manuel's mail class... Was not able to
send any kind of attachment except .txt files. Niether images nor pdf nor
anything would go through without being corrupted.

However, using Manuel's class, the images are going through attached
properly, without being corrupted. The PDF files still give the error that
the file size & read size isn't the same, but text and image attachments are
going through.

Junkie

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



Re: [PHP] Re: [PHP Attachement Problems - MAC ISSUE!!

2004-10-06 Thread PHP Junkie
Ave,

Manuel...

I saved the new email_message.php class that you sent me replacing the old
one. I used the test_attachment_message.php to test the new class. This time
it didn't send the email with the corrupted attachments, instead, gave me an
error on the screen... This is the error that I received:

³Error: the length of the file that was read does not match the size of the
part file CarsContract-Generic.pdf due to possible data corruption²

I understand now that garbage characters are being inserted by PHP in the
attachment files. Which is why also the other day when I tried your little
php code, it gave Size 35823 but Read 36704 with the additional garbage
characters added. Unfortunately, I think with the new class too, the same is
happening, as per the error. Only this time it is actually giving the error
instead of sending the corrupted file.

Please advice what I can do next... I¹m looking into the Mac compatibility
issue everywhere but I don¹t see anywhere anyone else complaining about such
a thing.

Thanks again,
Junkie



On 10/5/04 10:22 PM, "Manuel Lemos" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> On 10/05/2004 04:57 PM, PHP Junkie wrote:
>> I replaced the code and added my PDF file in the required place, and this is
>> what it displays now:
>> 
>> Size 35823 Read 36704
>> 
>> I'll put in your address and send out the mail your way with the PDF
>> attachment using the class script.
> 
> It seems that the problem has to due with garbage characters inserted by
> PHP during the read of the file because some PHP options set in your
> environment.
> 
> I have added a few workarounds to the class and it should avoid the
> problem now. I am sending you the new class version attached to this
> message. Please try it now and let me know if you still have problems.



Re: [PHP] Re: [PHP Attachement Problems - MAC ISSUE!!

2004-10-05 Thread Marek Kilimajer
PHP Junkie wrote:
Ave,
On a hunch.. I uploaded my original php script AND the php mime class to a
normal linux server with Apache web server... And all the scripts are
running fine! The PDF attachments go through fine.
So I finally found out.. It's a MAC issue! Using my scripts on the MAC
server is causing the problem. My problem however is, I have to use the MAC
and not a linux or windows or whatever. So what do I do now? How do I make
these scripts work fine on a MAC ??
Try direct connection to SMTP server, the class Manuel pointed to will 
help you with this.

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


Re: [PHP] Re: [PHP Attachement Problems - MAC ISSUE!!

2004-10-05 Thread PHP Junkie
Ave,

I replaced the code and added my PDF file in the required place, and this is
what it displays now:

Size 35823 Read 36704

I'll put in your address and send out the mail your way with the PDF
attachment using the class script.

Thanks a lot,

Junkie


On 10/5/04 3:51 PM, "Manuel Lemos" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> On 10/05/2004 04:40 PM, PHP Junkie wrote:
>> Really appreciate your help.
> 
> No problem. Sending mail with PHP is a saga to many users, not just
> Macs. If there is something that can be done to workaround PHP problems
> to avoid your problem, I will integrate it in that class.
> 
> 
>> I created a new empty php file and put your given code in it. Upon running
>> the test.php in my browser, it prints exactly this in my browser:
>> 
>> could not open file
> 
> Sorry, change it this way and replace your PDF file name where it says
> your-PDF-file-name-here.pdf .
> 
> 
>  $filename="your-PDF-file-name-here.pdf";
> $size=filesize($filename);
> if(!($file=fopen($filename,"rb")))
>die("could not open file ".$file_name);
> $data=fread($file,$size);
> echo "Size ",$size," Read ",strlen($data);
> fclose($file);
> ?>
> 
> 
>> I have a PowerMac G5 Machine, with MacOS X. I have PHP 5 installed from
>> entropy.ch and have the in-built Apache Web Server. Also, the MacOS X ships
>> with Postfix Mail Server and I used the Postfix Enabler to configure it. So
>> I use the Postfix Mail Server.
> 
> Hummm... there should be no problem. Can you try using the class script
> again and change it to send the message with the PDF attachment to:
> [EMAIL PROTECTED] ?

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



Re: [PHP] Re: [PHP Attachement Problems - MAC ISSUE!!

2004-10-05 Thread PHP Junkie
Manuel,

Really appreciate your help.

I created a new empty php file and put your given code in it. Upon running
the test.php in my browser, it prints exactly this in my browser:

could not open file

I have a PowerMac G5 Machine, with MacOS X. I have PHP 5 installed from
entropy.ch and have the in-built Apache Web Server. Also, the MacOS X ships
with Postfix Mail Server and I used the Postfix Enabler to configure it. So
I use the Postfix Mail Server.

Junkie



On 10/5/04 3:36 PM, "Manuel Lemos" <[EMAIL PROTECTED]> wrote:

>  $filename=$argv[1];
> $size=filesize($filename);
> if(!($file=fopen($filename,"rb")))
> die("could not open file ".$file_name);
> $data=fread($file,$size);
> echo "Size ",$size," Read ",strlen($data);
> fclose($file);
> ?>

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



Re: [PHP] Re: [PHP Attachement Problems - MAC ISSUE!!

2004-10-05 Thread PHP Junkie
Ave,

On a hunch.. I uploaded my original php script AND the php mime class to a
normal linux server with Apache web server... And all the scripts are
running fine! The PDF attachments go through fine.

So I finally found out.. It's a MAC issue! Using my scripts on the MAC
server is causing the problem. My problem however is, I have to use the MAC
and not a linux or windows or whatever. So what do I do now? How do I make
these scripts work fine on a MAC ??

Thanks,
Junkie



On 10/5/04 12:43 PM, "Manuel Lemos" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> On 10/04/2004 10:24 AM, Php Junkie wrote:
>> I created a form which can accept 2 file attachments and send an HTML
>> Email... Everything works great... The files even get attached and sent, the
>> ONLY problem is... The PDF file I'm sending attached open up empty! They are
>> all blank.. Like everything has been wiped off from them!!
> 
> It sounds like it is arriving corrupted.
> 
> You may want to try this other class you can used for the same purpose
> and AFAIK does not corrupt attachments:
> 
> http://www.phpclasses.org/mimemessage
> 

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



Re: [PHP] Re: PHP Attachement Problems

2004-10-05 Thread Greg Donald
On Tue, 05 Oct 2004 15:04:14 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote:
> I just tried your php mime class. I tried the test_attachment_message file.
> It did the same to the pdf attachment.

Have you tried sending other PDFs by chance?  Have you tried opening
the PDF with other PDF viewers after transfer?  Just curious if you've
localized the issue to PHP or not.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] Re: PHP Attachement Problems

2004-10-05 Thread PHP Junkie
Ave,

I just tried your php mime class. I tried the test_attachment_message file.
It did the same to the pdf attachment.

Initially, it tested with a text and an image. The text attachment opened
without a problem but the image was giving an error in opening. I left the
text file attachment as is and attached my pdf file .. And it gave the same
error in opening.

At this point I'm inclined to believe that any kind of php attachment script
is sending through any Text Attachment but not any other kind of attachment.

I'm running an Apache Web Server on a Mac... Would that make a difference?

Junkie.


On 10/5/04 12:43 PM, "Manuel Lemos" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> On 10/04/2004 10:24 AM, Php Junkie wrote:
>> I created a form which can accept 2 file attachments and send an HTML
>> Email... Everything works great... The files even get attached and sent, the
>> ONLY problem is... The PDF file I'm sending attached open up empty! They are
>> all blank.. Like everything has been wiped off from them!!
> 
> It sounds like it is arriving corrupted.
> 
> You may want to try this other class you can used for the same purpose
> and AFAIK does not corrupt attachments:
> 
> http://www.phpclasses.org/mimemessage
> 

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



[PHP] Re: [PHP Attachement Problems

2004-10-05 Thread Manuel Lemos
Hello,
On 10/04/2004 10:24 AM, Php Junkie wrote:
I created a form which can accept 2 file attachments and send an HTML
Email... Everything works great... The files even get attached and sent, the
ONLY problem is... The PDF file I'm sending attached open up empty! They are
all blank.. Like everything has been wiped off from them!!
It sounds like it is arriving corrupted.
You may want to try this other class you can used for the same purpose 
and AFAIK does not corrupt attachments:

http://www.phpclasses.org/mimemessage
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] [PHP Attachement Problems

2004-10-04 Thread PHP Junkie
Ave,

I created a form which can accept 2 file attachments and send an HTML
Email... Everything works great... The files even get attached and sent, the
ONLY problem is... The PDF file I'm sending attached open up empty! They are
all blank.. Like everything has been wiped off from them!!

Here's my code.. 

 method=post
ENCTYPE="multipart/form-data" name="f1" id="f1" >

  
From
(Name):

  
  
From
(Email):

  
  
To
(First,Last):


  
  
To
(Email):

  
  
Subject:

  
  
Message:

Test Message

  
  
Attachment
1 

  
  
Attachment
2 

  


  

","$from_name
<$from>",$subject);
 $m->mailbody($message_html, $message_html);
 if( $file1) {
$m->attachFile_raw($file1,$file1_name,$file1_type);
 };
 if( $file2)
{$m->attachFile_raw($file2,$file2_name,$file2_type);};
 $m->send();
?>

mailbody("This is simply text","This is HTML
text");
* $m->attach("example.html","text/html",$filebody);
* $m->attachFile("resume.gif","image/gif");
* $m->send();
*/

class CMIMEMail {
 var $to;
 var $boundary;
 var $smtp_headers;
 var $filename_real;
 var $body_plain;
 var $body_html;
 var $atcmnt;
 var $atcmnt_type;
 
 function CMIMEMail($to,$from,$subject,$priority=3) {
   $this->to=$to; $this->from=$from;
   $this->subject=$subject; $this->priority=$priority;
   $this->boundary="=_NextPart_".time()."_".md5(time())."_";
 }
 function  mailbody( $plain, $html="" ) {
   $this->body_plain=$plain;
   $this->body_html=$html;
 }
 function  attach( $name, $content_type, $data ) {
 }
 function  attachfile_raw( $fname, $mailFileName, $content_type ) {
   if([EMAIL PROTECTED]($fname,"r")) {
$this->atcmnt[$mailFileName]=fread($f,filesize($fname));
$this->atcmnt_type[$mailFileName]=$content_type;
fclose($f);
  } 
 }
 function  attachfile( $fname, $content_type ) {
attachfile_raw($fname,$fname,$content_type);
 }
 function  clear() {
   unset( $atcmnt );
   unset( $atcmnt_type );
 }
 function  makeheader() {
   $out ="From: ".$this->from."\n";
   $out.="Reply-To: ".$this->from."\n";
   $out.="MIME-Version: 1.0\n".
"Content-Type: multipart/mixed;\n\t boundary=\"".$this->boundary."\"\n".
"X-Priority: ".$this->priority."\n".
"X-Mailer: phpMimeMail ( http://www.informed-sources.com/ )\n";
   return $out;
 }
 function  makebody() {
   $boundary2= "=_NextAttachedPart_".time()."_".md5(time()+101)."_";
   $out="";
   if( " ".$this->body_html!=" " ) {
 $out="\nThis is a multi-part message in MIME format.\n\n";
 $out.="--".$this->boundary."\nContent-Type:
multipart/alternative;\n\tboundary=\"$boundary2\"\n";
 $out.="$body_plan\n".
   "--$boundary2\nContent-Type: text/plain\n".
#   "Content-Disposition: inline\n".
   "Content-Transfer-Encoding: quoted-printable\n\n".
   $this->body_plain.
   "\n\n--$boundary2\n".
   "Content-Type: text/html\n".
#   "Content-Disposition: attachment;\n\tfilename=\"message.html\"\n".
   "Conent-Transfer-Encoding: quoted-printable\n".
   "\n$this->body_html\n\n".
   "--$boundary2--\n";
   } else {
 $out="\n\n".$this->body_plain."\n\n";
 $out.="--".$this->boundary."\n".
"Content-Type: text/plain\n".
"Content-Transfer-Encoding: quoted-printable\n\n".
$this->body_plain.
"\n\n--".$this->boundary.
"\n";
   }
   if( is_array( $this->atcmnt_type ) ) {
 reset( $this->atcmnt_type);
 while( list($name, $content_type) = each($this->atcmnt_type) ) {
   $out.="\n--".$this->boundary."\nContent-Type:
application/pdf\nContent-Transfer-Encoding: base64\nContent-Disposition:
attachment; filename=\"$name\"\n\n".
 chunk_split(base64_encode($this->atcmnt[$name]))."\n";
 }   
   }
   $out.="\n--".$this->boundary."--\n";
   return $out;
 }
 function  send(){
   mail( $this->to, $this->subject, $this->makebody(),$this->makeheader() );
   echo "";
 }
}

?>

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



Re: [PHP] attachement

2002-11-10 Thread Jonathan Sharp
see http://phpmailer.sourceforge.net

-js


Oliver Witt wrote:
> Hi,
> I wrote a php script that's supposed to enable me to attach files to an
> email. However, the attached files ends up being a mess of letters.
> "Hallo" becomes "SGFsbG8=". That must have to do with encoding. Is that
> a common problem or do you need the entire script?
> Thanks,
> Olli
> 
> 




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




Re: [PHP] attachement

2002-11-10 Thread Oliver Witt
Ernest E Vogelsinger schrieb:

> At 15:27 10.11.2002, Oliver Witt said:
> [snip]
> >I had it set like this:
> >
> >$fp = fopen($file, "r");
> >$contents = fread($fp, $file_size);
> >$encoded_file = chunk_split(base64_encode($contents));
> >fclose($fp);
> >
> > ...
> >
> >$body.= "\n\n--Message-Boundary\n";
> >$body.= "Content-type: $file_type; name=\"$file_name\"\n";
> >$body.= "Content-Transfer-Encoding: PLAINTEXT\n";
> >$body.= "Content-disposition: attachment; filename=\"$file_name\"\n\n";
> >$body.= "$encoded_file\n";
> >$body.= "--Message-Boundary--\n";
> [snip]
>
> You must not give PLAINTEXT as encoding when you have it base64... use:
> Content-Transfer-Encoding: base64
>
> BTW, "PLAINTEXT" is not a MIME recognized encoding type. Excerpt from RFC2045:
>
> [snip]
> 5.2. Content-Type Defaults
> Default RFC 822 messages without a MIME Content-Type header are taken
> by this protocol to be plain text in the US-ASCII character set,
> which can be explicitly specified as:
>
> Content-type: text/plain; charset=us-ascii
>
> This default is assumed if no Content-Type header field is specified.
> It is also recommend that this default be assumed when a
> syntactically invalid Content-Type header field is encountered. In
> the presence of a MIME-Version header field and the absence of any
> Content-Type header field, a receiving User Agent can also assume
> that plain US-ASCII text was the sender's intent. Plain US-ASCII
> text may still be assumed in the absence of a MIME-Version or the
> presence of an syntactically invalid Content-Type header field, but
> the sender's intent might have been otherwise.
>
> 6.1. Content-Transfer-Encoding Syntax
> The Content-Transfer-Encoding field's value is a single token
> specifying the type of encoding, as enumerated below. Formally:
>
> encoding := "Content-Transfer-Encoding" ":" mechanism
>
> mechanism := "7bit" / "8bit" / "binary" /
>  "quoted-printable" / "base64" /
>  ietf-token / x-token
>
> These values are not case sensitive -- Base64 and BASE64 and bAsE64
> are all equivalent. An encoding type of 7BIT requires that the body
> is already in a 7bit mail-ready representation. This is the default
> value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the
> Content-Transfer-Encoding header field is not present.
> [snip]
>
> Therefore, for plaintext headings you should use
> Content-type: text/plain
> Content-Transfer-Encoding: 7bit (or 8bit, depends)
>
> --
>>O Ernest E. Vogelsinger
>(\)ICQ #13394035
> ^ http://www.vogelsinger.at/

thanks you very much, that's it, it's working perfectly now!!!
thx, Olli




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




Re: [PHP] attachement

2002-11-10 Thread Ernest E Vogelsinger
At 15:27 10.11.2002, Oliver Witt said:
[snip]
>I had it set like this:
>
>$fp = fopen($file, "r");
>$contents = fread($fp, $file_size);
>$encoded_file = chunk_split(base64_encode($contents));
>fclose($fp);
>
> ...
>
>$body.= "\n\n--Message-Boundary\n";
>$body.= "Content-type: $file_type; name=\"$file_name\"\n";
>$body.= "Content-Transfer-Encoding: PLAINTEXT\n";
>$body.= "Content-disposition: attachment; filename=\"$file_name\"\n\n";
>$body.= "$encoded_file\n";
>$body.= "--Message-Boundary--\n";
[snip] 

You must not give PLAINTEXT as encoding when you have it base64... use:
Content-Transfer-Encoding: base64

BTW, "PLAINTEXT" is not a MIME recognized encoding type. Excerpt from RFC2045:

[snip] 
5.2. Content-Type Defaults
Default RFC 822 messages without a MIME Content-Type header are taken
by this protocol to be plain text in the US-ASCII character set,
which can be explicitly specified as:

Content-type: text/plain; charset=us-ascii

This default is assumed if no Content-Type header field is specified.
It is also recommend that this default be assumed when a
syntactically invalid Content-Type header field is encountered. In
the presence of a MIME-Version header field and the absence of any
Content-Type header field, a receiving User Agent can also assume
that plain US-ASCII text was the sender's intent. Plain US-ASCII
text may still be assumed in the absence of a MIME-Version or the
presence of an syntactically invalid Content-Type header field, but
the sender's intent might have been otherwise. 

6.1. Content-Transfer-Encoding Syntax
The Content-Transfer-Encoding field's value is a single token
specifying the type of encoding, as enumerated below. Formally: 

encoding := "Content-Transfer-Encoding" ":" mechanism

mechanism := "7bit" / "8bit" / "binary" / 
 "quoted-printable" / "base64" /
 ietf-token / x-token

These values are not case sensitive -- Base64 and BASE64 and bAsE64
are all equivalent. An encoding type of 7BIT requires that the body
is already in a 7bit mail-ready representation. This is the default
value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the
Content-Transfer-Encoding header field is not present. 
[snip] 

Therefore, for plaintext headings you should use
Content-type: text/plain
Content-Transfer-Encoding: 7bit (or 8bit, depends)



-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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




Re: [PHP] attachement

2002-11-10 Thread Oliver Witt
Ernest E Vogelsinger schrieb:

> In your mail headers, you should see some MIME like
>
> Content-Type: multipart/alternative;
> boundary=GU4wuTSk68F
>
> ("alternative" could also read "related" - depends on the content, the
> "multipart" is the point here)
>
> which would tell the client browser that the next mail consists of a couple
> of separate parts, with a separator line as "--GU4wuTSk68F".
>

I had it set like this:

$fp = fopen($file, "r");
$contents = fread($fp, $file_size);
$encoded_file = chunk_split(base64_encode($contents));
fclose($fp);

unset($header);
$header = "FROM:$name_abs<$adresse_abs>\n";
$header.= "MIME-version: 1.0\n";
$header.= "Content-type: multipart/mixed; ";
$header.= "boundary=\"Message-Boundary\"\n";
$header.= "Content-transfer-encoding: 7BIT\n";
$header.= "X-attachments: $file_name";

$body = "--Message-Boundary\n";
$body .= "Content-type: text/plain; charset=US-ASCII\n";
$body .= "Content-Disposition: inline";
$body .= "Content-transfer-encoding: 7BIT\n";
$body .= "Content-description: Mail message body\n\n";
$body .= $text;
$body.= "\n\n--Message-Boundary\n";
$body.= "Content-type: $file_type; name=\"$file_name\"\n";
$body.= "Content-Transfer-Encoding: PLAINTEXT\n";
$body.= "Content-disposition: attachment; filename=\"$file_name\"\n\n";
$body.= "$encoded_file\n";
$body.= "--Message-Boundary--\n";

That's the same as a friend of mine uses it. He's saying it's working fine...
I'll try to do what you told me.
Olli


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




Re: [PHP] attachement

2002-11-10 Thread Ernest E Vogelsinger
At 14:31 10.11.2002, Oliver Witt said:
[snip]
>I wrote a php script that's supposed to enable me to attach files to an
>email. However, the attached files ends up being a mess of letters.
>"Hallo" becomes "SGFsbG8=". That must have to do with encoding. Is that
>a common problem or do you need the entire script?
[snip] 

It seems that you're encoding the file somehow - that's usual, even
required if your file is a binary file (like a picture, or a formatted
document).

In your mail headers, you should see some MIME like

Content-Type: multipart/alternative;
boundary=GU4wuTSk68F

("alternative" could also read "related" - depends on the content, the
"multipart" is the point here)

which would tell the client browser that the next mail consists of a couple
of separate parts, with a separator line as "--GU4wuTSk68F".

Next comes the message entity, which starts with such a separator line, and
a set of MIME headers for the respective entity:

--GU4wuTSk68F
Content-Disposition: inline
Content-Transfer-Encoding: 7bit
Content-Type: text/plain

You are receiving this message as a subscriber
to the Just For You Network. To cancel, see the
instructions at the end of this mail.

That's the first part of the mail - it's plain text. The next part would be
an image, and again starts with a boundary:

--GU4wuTSk68F
Content-Type: image/jpeg;
name="sample.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="sample.jpg"

JVBERi0xLjMNJeLjz9MNCjE5OSAwIG9iag08PCANL0xpbmVhcml6ZWQgMSANL08gMjAy
JVBERi0xLjMNJeLjz9MNCjE5OSAwIG9iag08PCANL0xpbmVhcml6ZWQgMSANL08gMjAyIA0vSCBb
IDE2NDUgMjc0IF0gDS9MIDEwOTMzMSANL0UgNzg3MDYgDS9OIDMgDS9UIDEwNTIzMiAN
IDE2NDUgMjc0IF0gDS9MIDEwOTMzMSANL0UgNzg3MDYgDS9OIDMgDS9UIDEwNTIzMiANPj4gDWVu
[...]
RHA0NjcxUFJGbzgtMTZsNDM=

--GU4wuTSk68F

The message should also end with a boundary, but most mail client's omit
this...

For more information consult RFC2045 ff about MIME

ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt

Hope this helps,

-- 
   >O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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




Re: [PHP] attachement

2002-11-10 Thread Rick Emery
Here is a PHP mail class that handles multiple attachments and several other functions:

mailbody("This is simply text","This is HTML text");
* $m->attach("example.html","text/html",$filebody);
* $m->attachFile("resume.gif","image/gif");
* $m->send();
* NOTE: if your system have chunk_split function use it.
***
* To Do:
* 1. Make quoted-printable encoder and use them in makebody;
* 2. Generate right boundaries
* 3. Fix bugs in  SMTP send direct futction SMTPsend()
*/

function my_chunk_split($str)
{
$stmp = base64_encode($str);
$len = strlen($stmp);
$out =  "";
$done=0;
while( $done<$len ) {
  $out.=( $len-$done>76)?substr($strp,$done, 76). "\r\n":substr($strp,$done,
$len-$done). "\r\n";
  $done+=76;

}
return $out;
}


class CMIMEMail {
 var $to;
 var $from;
 var $cc;
 var $bcc;
 var $subject;
 var $priority;
 var $boundary =  "=_NextPart_000_0009_01BF95E9.CDFD2060";
 var $smtp_headers;
 var $filename_real;
 var $body_plain;
 var $body_html;
 var $atcmnt;
 var $atcmnt_type;
 function CMIMEMail($to,$from,$subject,$cc="",$bcc="",$priority=3) {
   $this->to=$to; $this->from=$from; $this->subject=$subject;
   $this->priority=$priority; $this->cc=$cc; $this->bcc=$bcc;
 }
 function  mailbody( $plain, $html= "" ) {
   $this->body_plain=$plain;
   $this->body_html=$html;
 }
 function  attach( $name, $content_type, $data ) {
   $this->atcmnt[$name]=$data;
   $this->atcmnt_type[$name]=$content_type;
 }
 function  attachfile( $fname, $content_type ) {
   $name=ereg_replace( "(.+/)", "",$fname);
   $f=fopen($name, "r");
   $fsz = filesize($name);
   $ftext = fread($f,$fsz);
   $this->attach($name,$content_type,$ftext);
   fclose($f);
 }
 function  clear() {
   unset( $this->atcmnt );
   unset( $this->atcmnt_type );
 }
 function  makeheader() {
   $out = "From: ".$this->from."\nReply-To: ".$this->from. "\n";
   if( $this->cc !="")  $out .="Cc: ".$this->cc."\n";
   if( $this->bcc !="") $out .="Bcc: ".$this->bcc."\n";
   $out.= "MIME-Version: 1.0\nContent-Type: multipart/mixed;\n
boundary=\"".$this->boundary. "\"\nX-Priority: ".$this->priority. "\n";
   return $out;
 }
 function  makebody() {
   $boundary2=  "=_NextPart_001_0009_01BF95E9.CDFD2060";
   $out= "";
   $out= "\n\n".$this->body_plain. "\n\n";
   if( $this->body_html!= "" ) {
 $out.= "--".$this->boundary. "\nContent-Type: multipart/alternative;\n
boundary=$boundary2\n\n";
 $out.= "$body_plain\n--$boundary2\nContent-Type:
text/plain\nContent-Transfer-Encoding: quoted-printable\n\n".$this->body_plain.
"\n\n--$boundary2\nContent-Type: text/html\n".
"Content-Transfer-Encoding:
quoted-printable\n\n$this->body_html\n\n--$boundary2--\n";
   } else {
# $out.= "--".$this->boundary. "\nContent-Type: 
text/plain\nContent-Transfer-Encoding:
quoted-printable\n\n".$this->body_plain. "\n\n--".$this->boundary. "\n";
 $out.= "--".$this->boundary. "\nContent-Type: 
text/plain\nContent-Transfer-Encoding:
quoted-printable\n\n".$this->body_plain. "\n\n";
   }
   if( ISSET($this->atcmnt_type) )
   {
   reset( $this->atcmnt_type);
   while( list($name, $content_type) = each($this->atcmnt_type) ) {
 $out.= "\n--".$this->boundary. "\nContent-Type:
$content_type\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment;
filename=\"$name\"\n\n".
   chunk_split(base64_encode($this->atcmnt[$name])). "\n";

   } }
   $out.= "--".$this->boundary. "--\n";
   return $out;
 }
 function  send(){
   mail( $this->to, $this->subject, $this->makebody(),$this->makeheader() );
 }
 function  sendto($email,$subj="#"){
   if( $subj=="#") $subj= $this->subject;
   mail( $email, $subj, $this->makebody(),$this->makeheader() );
 }
 function  SMTPsend($host){
   $errno=0;$errstr= "";
//   $f=fsockopen("127.0.0.1",25,&$erno, &$errstr);
   if(!$f) {
 $this->send();
   } else {
  //SNMP commands Not finished yet
  echo fgets($f,512);
 fputs($f, "HELO host.com\n");
  echo fgets($f,512);
  fputs($f, "MAIL FROM: ".$this->from. "\n");
  echo fgets($f,512);
  fputs($f, "RCPT TO: ".$this->to). "\n";
  echo fgets($f,512);
 fputs($f, "data\n");
  echo fgets($f,512);
 fputs($f, "

[PHP] attachement

2002-11-10 Thread Oliver Witt
Hi,
I wrote a php script that's supposed to enable me to attach files to an
email. However, the attached files ends up being a mess of letters.
"Hallo" becomes "SGFsbG8=". That must have to do with encoding. Is that
a common problem or do you need the entire script?
Thanks,
Olli


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