giftdate.blogg.se

Php imap get plain text
Php imap get plain text










$body = trim(substr(quoted_printable_decode($body), 0, 100))

#PHP IMAP GET PLAIN TEXT CODE#

Use this next code to replace the existing call to imap_body() : So, to get around this, the easiest thing to do is use imap_fetchbody() to request sub-part 1 of part 1, and, if it is empty, just request part 1. Most mail readers send the plain text as the first part, although this is not universally true - AOL, for example, often combines the HTML and plain text into one part of two sub-parts. Each MIME-encoded message can be broken down into parts based upon the its contents: each attachment can be considered a part. As a result, if all you want to do is grab the plain text portion of a message, you can just request part 1 and not have your script download anything else.

php imap get plain text

This takes an IMAP stream, a message number, and a part number as its parameters, and returns the text of that part. Of course, what we would rather it do would be to scan through the plain text in the document and take the first hundred characters of that, but to get to that point we need to break down the MIME type into parts and only retrieve the plain text section.įortunately, PHP has a function just for that purpose: imap_fetchbody(). As our previous script just read the first 100 characters of text from the body, it would read this:

php imap get plain text php imap get plain text

X8kwlcC65mZpB2kKaQ1pEGmTKY9eZs2EHBwccxFsQg4Oj+P/r0YF809KwLwAAAAASUVORK5CYII=Īs you can see, the plain text, HTML, and PNG files are all in there buried amongst MIME headers and boundary markings. IVBORw0KGgoAAAANSUhEUgAAASwAAAA8CAIAAAEkuSCbAAAACXBIWXMAAAsSAAALEgHS3X78AAAAĬXRFWHRDb21tZW50AACJKo0GAAAJL0lEQVR4nO2da2wc1RXH/zPr2dibJeFlUMCxDWSBD7y0YEUb Boundary="=_ecd64c2382d54d7d8b2d1e3ecaafdcb1"Ĭontent-Type: text/plain charset="ISO-8859-1"Ĭontent-Type: text/html charset="ISO-8859-1"Ĭontent-Transfer-Encoding: quoted-printableĬontent-Disposition: attachment filename="button.png"










Php imap get plain text