View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
05079Bug reportsSurvey participants (Tokens)public2011-04-11 11:34
Reporterpeterhol Assigned Touser7171 
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.91RC5 
Fixed in Version1.91RC6 
Summary05079: Bounce emails aren't registered/error messages
Description

Bounce emails aren't registered. Sometimes when I "process bounce emails" I receive error messages (IMAP header errors, mostly referring to tokens.php I think... but am not totally sure – as they generally only appear once... after that it only says "0 messages scanned, none marked as bounces by the system"... even though I can see in the email account used for bounce emails that there are many bounces – unread emails – if that makes any difference...

Steps To Reproduce
  • create survey with tokens, create tokens, fill out bounce email handling (and double checking that the settings are correct, I've tried both using POP and IMAP, ssl and no ssl) , start survey and send out tokens.
  • check email account that there are a number of bounces
  • go to the survey tokens admin screen and process bounces
  • no entries are marked as "email bounced"
Additional Information

I'm not a big bug reporter, and don't know if the information I've supplied is sufficient... but I'll be happy to provide additional information/testing – contact me on peter@holme.se.

TagsNo tags attached.
Attached Files
patch.txt (936 bytes)   
Index: tokens.php
===================================================================
--- tokens.php	(revision 9877)
+++ tokens.php	(working copy)
@@ -304,6 +304,9 @@
 			$datelcu = strtotime($lasthinfo->date);
 			$datelastbounce= $datelcu;
 			$lastbounce = $thissurvey['bouncetime'];
+			$earliestinfo=imap_headerinfo($mbox,1);
+			$earliestdate=strtotime($earliestinfo->date);
+			if($lastbounce<$earliestdate) $lastbounce=$earliestdate;
 			while($datelcu > $lastbounce)
 			{
 				$header = explode("\r\n", imap_body($mbox,$count,FT_PEEK)); // Don't put read
@@ -334,8 +337,8 @@
 				$datelc=$lasthinfo->date;
 				$datelcu = strtotime($datelc);
 				$checktotal++;
-			    imap_close($mbox);
             }
+			imap_close($mbox);
 			$entertimestamp = "update ".db_table_name("surveys")." set bouncetime='$datelastbounce' where sid='$surveyid'";
 			$executetimestamp = $connect->Execute($entertimestamp);
 			if($bouncetotal>0)
patch.txt (936 bytes)   
Bug heat4
Complete LimeSurvey version number (& build)9877
I will donate to the project if issue is resolvedYes
Browserchrome/safari/firefox on a mac
Database type & versionmysql 5.0.91, 145
Server OS (if known)linux
Webserver software & version (if known)Apache/2.2.17
PHP Version5.2.16

Users monitoring this issue

There are no users monitoring this issue.

Activities

peterhol

peterhol

2011-04-04 12:50

reporter   ~14648

Here are the errors I talked about from error.log... these are given sometimes even when I use POP...

[04-Apr-2011 02:12:08] PHP Warning: imap_body(): 41 is not a valid imap resource in /home/xyz/public_html_lime/admin/tokens.php on line 309
[04-Apr-2011 02:12:08] PHP Warning: imap_headerinfo(): 41 is not a valid imap resource in /home/xyz/public_html_lime/admin/tokens.php on line 333
[04-Apr-2011 02:12:08] PHP Warning: imap_close(): 41 is not a valid imap resource in /home/xyz/public_html_lime/admin/tokens.php on line 337

peterhol

peterhol

2011-04-04 14:00

reporter   ~14653

Last edited: 2011-04-04 14:11

hmm... I messed around a bit with said lines in tokens.php, and changed the occurances of $mbox to imap_open('{'.$hostname.$flags.'}INBOX',$username,$pass)... ran the script again... and all (i think) of the bounces were marked! I did get an error message of a wrong message number though.. so... it seems something is wacky with the $mbox variable...

peterhol

peterhol

2011-04-04 14:02

reporter   ~14654

btw.. for testing purposes, I also changed line 306 from
$lastbounce = $thissurvey['bouncetime'];
to
$lastbounce = 0; // $thissurvey['bouncetime'];

peterhol

peterhol

2011-04-04 14:31

reporter   ~14655

ok.. another way to get the tokens marked as bounced, was to move line 337 down two lines.. so it is outside the loop.. then all the messages are checked ( i think) – and I only get this error message:

Warning: imap_headerinfo() [function.imap-headerinfo]: Bad message number in /home/xyz/public_html_lime/admin/tokens.php on line 333

user7171

2011-04-04 14:46

  ~14656

Hey peterhol,

Thanks for bringing it to our notice. The warning messages have been suppressed, and now should not show up. Your last workaround is correct , I mean bringing the imap_close two lines below so that it is out of the while loop and hence not closing the connection before checking all the mails correctly is correct and hence have been changed and committed.

Thanks
Anish Seth

peterhol

peterhol

2011-04-04 16:11

reporter   ~14657

goody ;) but i still get this other error message the first time I check for bounces:

Warning: imap_headerinfo() [function.imap-headerinfo]: Bad message number in /home/dinamome/public_html_lime/admin/tokens.php on line 333

I've checked it and it appears when $lastbounce is set to a time older than the oldest mail in INBOX! (I assume the first time it is run, $lastbounce = 0;. So... I tried setting $lastbounce (in line 306) to the following timestamps, and got the following results:
$lastbounce = 0; ERROR!
$lastbounce = 1301514567; ERROR!
$lastbounce = 1301514568; NO ERROR (this is the time of the first mail in INBOX)
$lastbounce = 1301514569; NO ERROR!

peterhol

peterhol

2011-04-04 16:19

reporter   ~14658

basically … I think the loop runs one time too many when $lastbounce is less than the earliest timestamp in INBOX... possibly...

peterhol

peterhol

2011-04-04 16:37

reporter   ~14659

OK I think I got it :) I added these lines after line 306:

        $earliestinfo=imap_headerinfo($mbox,1);
        $earliestdate=strtotime($earliestinfo->date);
        if($lastbounce&lt;$earliestdate) $lastbounce=$earliestdate;

and no more error message :)

peterhol

peterhol

2011-04-04 16:42

reporter   ~14660

Last edited: 2011-04-04 16:44

patch added :) The only thing is that I don't think this takes into account what happens if INBOX is empty...

user7171

2011-04-04 17:37

  ~14661

Hey Peterhol,

Again thanks for reporting this. The actual problem is not the time variable, but the fact that the count variable will go zero if there are no messages in the inbox then throws the bad variable error, which now has been handled and committed. Please have a look and let me know

Thanks
Anish Seth

peterhol

peterhol

2011-04-04 17:49

reporter   ~14662

it works :)

user7171

2011-04-04 17:52

  ~14663

Resolved and committed.

Issue History

Date Modified Username Field Change
2011-04-04 09:42 peterhol New Issue
2011-04-04 11:06 c_schmitz Assigned To => user7171
2011-04-04 11:06 c_schmitz Status new => assigned
2011-04-04 12:50 peterhol Note Added: 14648
2011-04-04 14:00 peterhol Note Added: 14653
2011-04-04 14:02 peterhol Note Added: 14654
2011-04-04 14:11 peterhol Note Edited: 14653
2011-04-04 14:31 peterhol Note Added: 14655
2011-04-04 14:46 user7171 Note Added: 14656
2011-04-04 14:47 user7171 Status assigned => feedback
2011-04-04 16:11 peterhol Note Added: 14657
2011-04-04 16:11 peterhol Status feedback => assigned
2011-04-04 16:19 peterhol Note Added: 14658
2011-04-04 16:37 peterhol Note Added: 14659
2011-04-04 16:42 peterhol File Added: patch.txt
2011-04-04 16:42 peterhol Note Added: 14660
2011-04-04 16:44 peterhol Note Edited: 14660
2011-04-04 17:37 user7171 Note Added: 14661
2011-04-04 17:37 user7171 Status assigned => feedback
2011-04-04 17:49 peterhol Note Added: 14662
2011-04-04 17:49 peterhol Status feedback => assigned
2011-04-04 17:52 user7171 Note Added: 14663
2011-04-04 17:52 user7171 Status assigned => resolved
2011-04-04 17:52 user7171 Resolution open => fixed
2011-04-11 11:34 c_schmitz Fixed in Version => 1.91RC6
2011-04-11 11:34 c_schmitz Status resolved => closed
2016-12-08 10:39 c_schmitz Category Tokens => Survey participants (Tokens)