Jump to content

imap_body adds newlines in messagebody


kutchbhi

Recommended Posts

$mail_headers = imap_headerinfo($inbox, $emails[0]);
$head = imap_fetchheader($inbox, $mail_headers->Msgno, FT_INTERNAL &  FT_PREFETCHTEXT );
$mail_body = imap_fetchbody($inbox, $mail_headers->Msgno, '1', FT_INTERNAL);
// file_put_contents('spotify.csv', $mail_body) ;
print_r($mail_body) ;
     

I am trying to read a message from a pop3 email account. the email which contains a csv file as text, 

 

When I try to print_r the email_body it contains more new lines than what it had originally. My guess is that the imap_fetch functions are inserting newlines inside the text (to make it readable).

 

How do I prevent this ?

Link to comment
https://forums.phpfreaks.com/topic/283235-imap_body-adds-newlines-in-messagebody/
Share on other sites

Have you tried adding FT_INTERNAL to the imap_fetchbody $options.

string imap_fetchbody ( resource $imap_stream , int $msg_number , string $section [, int $options = 0 ] )

FT_INTERNAL - The return string is in internal format, will not canonicalize to CRLF.

Not 100% sure that'll do what you want, as I've never personally worked with this function before, but reading that it looks like by default it changes it to CRLF.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.