HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

Tasks.php not deleting emails from POP3 mail


Does anyone encounter the Tasks.php file does not delete all the emails from the Pop3mail?

I noticed that I was getting responses from emails that were already closed, then the helpspot gets the response email from the customer, but for some reason doesn’t delete, it, which this email causes the ticket to open each time helpspot picks it up.


Hi Ruell,

We have no other reports of this on file. Ryan just emailed in and there’s still some configuration items I had sent him in a previous email that you guys need to try. It could also be a problem with your mail server, but changing the timing of tasks.php is a first step.


Hi Ian,

We fixed the tasks to run for up to 3 minutes on the scheduled tasks using the VB script that you have available on the site. The task is running every 5 minutes for now. Let me know if you have any other suggestions why this might be happening.


Hi Ian,

I did some troubleshooting and testing and noticed that tickets that are reopened if they were closed previously are the ones not being downloaded and removed from the smtp server. If the email was a new ticket, it deletes them eliminating the possibility of being duplicated.

This explains why the ticket keeps being reopened because i believe when tasks.php is being run again, it is taking the email once again, that was not removed from the SMTP server. Would you know if there’s a reason why they are not being deleted?

I am 100% it only occurs on reopened tickets that were closed before.


I also tried to play with the settings in the email integration such as setting the reopen ticket function to zero, or to 6, and doing things like changing the compare email to prevent loop setting it to 0 to up to 600 seconds but no luck.


I did some testing with the task.php output on a browser and noticed the following:

Connecting to: >>>> Message Count: 2 >>>> Message: #1 - Time (start parse): 0.00027 >>>> Message: #1 - Time (network download): 0.22174 >>>> Message: #1 - Time (mime decode): 0.22854 >>>> Message: #1 - Time (mime loop): 0.22875 >>>> Message: #1 - Ruell >>>> Message: #1 - Time (header set): 0.23133 >>>> Message: #1 - Time (attachments): 0.23149 >>>> Message: #2 - Time (start parse): 0.00018 >>>> Message: #2 - Time (network download): 0.40315 >>>> Message: #2 - Time (mime decode): 0.40764 >>>> Message: #2 - Time (mime loop): 0.40783 >>>> Message: #2 - Ruell >>>> Message: #2 - Time (header set): 0.40999 >>>> Message: #2 - Time (attachments): 0.41013 >>>> Message: #2 - Request created (14949) >>>> Message: #2 - Marked for deletion from mailserver >>>> Message: #2 - Time (total): 0.44230 >>>> Expunged messages marked for deletion >> Closed connection to: >> Connecting to: support@ >> Closed connection to: support@

Message #1 was a reopened ticket and Message #2 is a new ticket. I noticed #1 does not get the Marked for deletion from mailserver notice on #1 and explains why the email is left on the server. It also explains why it keeps in the db and each time the task.php runs it pulls that email again and makes the ticket history get several of the same emails, and also reopens the ticket even though Its already closed and completed.


Have you upgraded to 1.5.5 yet? If not upgrade and let me know if that helps this.


yes, i am running on 1.5.5 and I made sure all the files were updated using the clean upgrade method.


What operating system and version of PHP are you running Ruell?


i’m using windows 2000 server, with iis 5.0 and PHP 5.2.0 and zend optimizer v3.2.0

The reason I chose this combo is I had difficulty getting the lower PHP/Zend combos with MYsqli 5.0

Let me know if you see any issues using this setup and if that can cause issues.



Well HelpSpot isn’t tested in this configuration, especially IIS 5. There are people using this configuration, but it’s not recommended.

Do you have a Win2003 server or Linux server that you could install and test HelpSpot out on?


i will see if i can do the transfer to a higher version system. Are you confident this would solve the issue? (upgrading to IIS 6.0 on 2003)


Well I’m confident that I don’t have any reports like this in that configuration. If the problem is with your mail server then this change will not fix that. You could try installing it on 2003 on a test server first to see if that works before moving it to production.


I just upgraded our service to IIS 6.0 and PHP 5.2.0 with Zend 3.2.0 and it still does the same characteristic as before. Emails that reopen an older closed response is not purged from the DB.


Do you know what mail server you’re using? Would it be possible for you to setup a test account for me on that mail server so that I can try from an installation here to access it and see what happens.


we are using Merak Mail Server. My curiousity is why it would be the mail server that has the point of failure when it doesn’t know whether it is a reopened ticket or a brand new ticket. The tasks.php output when shown on the browser shows it as marking the message for deletion if the email was new, but if there is an existing ticket in the system already pertaining to the email that is in the pop mailbox, it negates this statement.

i will email you a test account shortly.


OK, this was a tricky one!

The problem I “think” is that your mail server is slow. So when HelpSpot tries to download the message it takes longer than the PHP settings allow and times out, so the mail server never gets sent the delete command.

Ideally you would like the mail server to respond faster. It’s taking more than 60 seconds on moderate size emails which is why it times out, because 60 seconds is the default. Since speeding up your mail server may not be possible you can instead increase the timeout by changing the “default_socket_timeout” variable in your php.ini file and restarting your web server.

One note though is that with the mail server running so slow you could end up having duplicate requests on occasion as well since tasks.php might get called while a previous instance is still running.

In any event try increasing that variable and see if that helps.


I tried increasing the timeout as you suggested but no luck. Can you let me know how you conclude it’s the mail server is slow? At times I can get 20 emails without any problem, no duplication, but only emails that were pertaining to reopened tickets or existing tickets are the ones that do not get deleted.

Please note I mentioned it DOES delete the email if the email was a new request, but if it had an existing ticket from a previous request or a reopen request, it DOES NOT delete it. And this happens from the same tasks.php instance that is executed and completed within 10 seconds. Please review the shown tasks.php output from a browser. I’ve broken it down and put in () comment’s i made on what I observed. Note the following is being tested using a completely different mail server (microsoft exchange setup with POp3 on same internal network) and same result.

(Tasks.php connects to exchange mail server, Message #1 is a new request, Message #2 is previously closed ticket in Helpspot that is replied to and reopened)

Connecting to: support@ >>>> Message Count: 2 >>>> Message: #1 - Time (start parse): 0.00023 >>>> Message: #1 - Time (network download): 0.00643 >>>> Message: #1 - Time (mime decode): 0.01173 >>>> Message: #1 - Time (mime loop): 0.01191 >>>> Message: #1 - >>>> Message: #1 - Time (header set): 0.01398 >>>> Message: #1 - Time (attachments): 0.01411 >>>> Message: #1 - Request created (15292) >>>>

(after numerous hours of debugging I noted that this is the command that is sent that actually deletes the email from the pop server) Message: #1 - Marked for deletion from mailserver >>>> Message: #1 - Time (total): 0.04592 >>>> (message #1 was deleted from server)

(message #2 is a response from customer to an existing ticket)
Message: #2 - Time (start parse): 0.00013 >>>> Message: #2 - Time (network download): 0.00653 >>>> Message: #2 - Time (mime decode): 0.01145 >>>> Message: #2 - Time (mime loop): 0.01163 >>>> Message: #2 - Ruell >>>> Message: #2 - Time (header set): 0.01364 >>>> Message: #2 - Time (attachments): 0.01377 >>>> Expunged messages marked for deletion >> (notice this message does not have the command like in #1 that states message marked for deletion in server)

(tasks.php file completed)
Closed connection to: support@

This process took less than 5 seconds to execute completely, and when I checked the helpspot both emails were in the system, but Message #2 was not deleted from the Pop server. Please consider my input that it has something to do with the fact the message marked for deletion command on tasks.php for some reason is not being executed when the ticket had a previous entry either opened or closed. This explains why we used to get multiple emails of the same response because each time tasks.php runs it is not deleting them from the server, and has nothing to do with being a slow email server.

If we could get over this issue I think the system will work perfectly!



OK, well what lead me to think that was on the other account for very small emails in the (network download) section it was taking 50-60 seconds. These times posted above though are fine.

Can you tell me what the setting in Admin->Settings->Email Integration->Reopening Closed Requests is? If it’s 0 try making 15 or something like that, if it’s not 0 make it 0 and see if that changes anything.


OK what I’m going to do is put together some modified versions of tasks.php with more debugging info and some test changes to how it works to see what’s wrong.

I should have something to you by the end of the day today.