#native_company# #native_desc#
#native_cta#

Using PHP for RTF Page 4

By Sujith Nair
on May 22, 2002

Another alternative for defining the scope is by closing the control
with a ‘0’. That is,
when such a control word (like b) has no parameter or has a nonzero
parameter (like b1), it is assumed
that the control word turns on the property. When such a control word
has a parameter of 0 (like b0),
it is assumed that the control word turns off the property. For example,
b turns on bold, whereas b0
turns off bold. It’s not over yet. The most important part is, we have to
take care of all the “n”, “r”
and “t”s in the document. Best way to deal with it is to escape all
“”s preceding ‘r’,’n’ and ‘t’ before
writing to a file. For newlines we can make use of “par”.
Now I was left with only one thing: to send email attachment of RTF
files. After I
was able to write an RTF file, it didn’t seem difficult. All I did
was define a
Content-Type of “multipart/mixed” as parent, “text/plain” for message
and “text/rtf” for
the attachment. I will show you how.

<?php

// the preceding part of the mail remains as same as that of a normal

// mail.

fputs($fd"Content-Type: multipart/mixed; boundary=$boundry nn");

fputs($fd"Content-Transfer-Encoding: 7bit n");

fputs($fd"This is a multi-part message in MIME format nn");

fputs($fd"--$boundry n");

fputs($fd"Content-type: text/plain; charset=us-ascii n"); 

fputs($fd"Content-Transfer-Encoding: 7bit n");

fputs($fd"n");

fputs($fd" message is thisn"); // message goes here

fputs($fd"--$boundry n");

fputs($fd"Content-type: application/rtf; charset=us-ascii n"); 

fputs($fd"Content-Transfer-Encoding: 7bit n");

fputs($fd"Content-Disposition: inline; filename="mailer.rtf" n");

fputs($fd"Content-Base: "file///c|/temp/mailer.rtf" rnrn");

// the succeeding part of the mail remains as same as that of a normal

// mail.

?>