Hey all,
Anyone know anything about using Mail_mimeDecode?
I'm writing an interface that reads email from a database, and am trying to support both MySQL and PostgreSQL. So far I've been concentrating on MySQL as the database backend, but just recently started to make sure the SQL scripts will work for PostgreSQL - and this is where I noticed the problem.
I got all the SQL to work, returning all the data that it should, but am having difficulty using Mail_mimeDecode to decode the information.
I do not have a problem when viewing the actual email, but the problem comes when I am viewing the list. The SQL queries grab just the headers from the mail (stored separate from the body), as I shouldn't need the body to get the From and Subject headers.
When generating the list and looping through the returned email, I run the following code:
That is in a loop grabbing all the messages to be displayed.
It works fine when pulling data from MySQL (ie the Subject and From gets populated correctly), but when the database is PostgreSQL it doesn't decode properly. I've verified that the data is actually pulling from the database (using print_r($n); exit(), it just doesn't seem to be decoding (which does work fine, when the body is included during the view email process).
Sorry for the long-winded post, I just wanted to include enough information.
Thanks.
Anyone know anything about using Mail_mimeDecode?
I'm writing an interface that reads email from a database, and am trying to support both MySQL and PostgreSQL. So far I've been concentrating on MySQL as the database backend, but just recently started to make sure the SQL scripts will work for PostgreSQL - and this is where I noticed the problem.
I got all the SQL to work, returning all the data that it should, but am having difficulty using Mail_mimeDecode to decode the information.
I do not have a problem when viewing the actual email, but the problem comes when I am viewing the list. The SQL queries grab just the headers from the mail (stored separate from the body), as I shouldn't need the body to get the From and Subject headers.
When generating the list and looping through the returned email, I run the following code:
Code:
$msgHeader = $n['messageblk'];
$decode = new Mail_mimeDecode($msgHeader);
$args = array();
$args['include_bodies'] = true;
$args['decode_bodies'] = true;
$args['decode_headers'] = true;
$args['input'] = '';
$args['crlf'] = "\r\n";
$structure = $decode->decode($args);
$ret_data['msg'][$i]['subject'] = $structure->headers['subject'];
$ret_data['msg'][$i]['from'] = $structure->headers['from'];
That is in a loop grabbing all the messages to be displayed.
It works fine when pulling data from MySQL (ie the Subject and From gets populated correctly), but when the database is PostgreSQL it doesn't decode properly. I've verified that the data is actually pulling from the database (using print_r($n); exit(), it just doesn't seem to be decoding (which does work fine, when the body is included during the view email process).
Sorry for the long-winded post, I just wanted to include enough information.
Thanks.