Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:09:59+00:00 2026-06-11T12:09:59+00:00

I have a script that checks emails and puts them in a database. This

  • 0

I have a script that checks emails and puts them in a database. This works fine when new emails are composed and sent. However, if I reply to an email the imap_fetchbody does not work and it is empty.

Where am I going wrong here?

/* get information specific to this email */
$overview = imap_fetch_overview($inbox,$email_number,0);
$structure = imap_fetchstructure($inbox,$email_number);
$message = imap_fetchbody($inbox,$email_number,0);
$header = imap_headerinfo($inbox,$email_number);

//print_r($structure);

  //make sure emails are read or do nothing
if($overview[0]->seen = 'read'){  

//strip everything below line
$param="## In replies all text above this line is added to the ticket ##";
$strip_func = strpos($message, $param);
$message_new = substr($message,0,$strip_func );


  /* output the email body */
  $output.= '<div class="body">'.$message_new.'<br><br></div>';

If I output the $message instead of the $message_new so before I start stripping the text everything is displayed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:10:01+00:00Added an answer on June 11, 2026 at 12:10 pm

    If that line “In replies…” is not present in the message at all, strpos will return boolean false, which when coerced to an integer will be 0.

    So when you ask for the substring from 0 to the position, you’re asking for the substring from 0 to 0, and $message_new is empty.

    Check if that line is present in the mail before you try to take a substring based on it.

    $param="## In replies all text above this line is added to the ticket ##";
    $strip_func = strpos($message, $param);
    $message_new = ($strip_func === false) ? $message : substr($message,0,$strip_func);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having this issue. I have a script that checks if variable exists,
I have a script that checks something on my PC every 5 minutes and
I have a script (or more accurately WILL have a script) that checks a
I have a little script that checks for cookies and I was wondering how
Ok, I have a validation script that checks everything on the form - but
I have an existing python script that, among other things checks a file against
I have this script that collects data from users and I want to check
I have this simple code that speaks for itself. <script language='javascript"> function check() {}
I have a PHP script that logs informational and error messages to a database
I have a shell script that periodically checks the ADSL external IP address and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.