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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.