Benjamin Allison
Benjamin Allison

Reputation: 2154

Reading binary email attachment (CSV) with PHP

We're receiving automated emails, which have a CSV attached. Using PHP, I'm grabbing mail via IMAP. I can grab the eMails and attachments no problem. However, the CSV's are attached as octet-streams.

How can I convert that to something I can actually work with? Currently when reading the contents, I'm just getting stuff that looks like this:

NzA1MTA1NTgxMzAsODgxDQo3MDUxMDU1ODEyMCw1NzkNCjcwNTEwNTU4MTEwLDQ3MQ0KNzA1MTA1==

Upvotes: 0

Views: 758

Answers (1)

Brad
Brad

Reputation: 163301

Use base64_decode().

http://php.net/manual/en/function.base64-decode.php

Better yet, look at the encoding headers in the e-mail so that you know whether or not something is actually encoded the way you expect.

Upvotes: 2

Related Questions