RestyaPlatform / board

Trello like kanban board. Based on Restya platform.
http://restya.com/board/
Open Software License 3.0
2.04k stars 382 forks source link

Can't receive IMAP mails as cards #4043

Closed dragonauta closed 4 years ago

dragonauta commented 4 years ago

Expected Behavior

Email account created: rbreply@mydomain.com E-mails sent to rbreply+x+xxxxxxxxxxxxxxx@mydomain.com would add a card into Board (defined by the 'plus' destination)

Current Behavior

Nothing happens, mails are received by account (can see them in thunderbird), but not into boards as cards.

Possible Solution

I saw that "diagnose.php" shows imap and imagick as orange. php7.2-imap is installed through install script. (under Debian 10 should PHP from official repos) Also it doesn't install php7.2-gd (in red, could fix it installing manually)

Steps to Reproduce (for bugs)

  1. Create email account (hosting allow "Automatically Create Folders for Plus Addressing")
  2. Test imap with thunderbird
  3. Install restyaboard with installer script (later I removed apache2 as it get installed)
  4. First login and configuration: correct IMAP settings
  5. Create a board and take note of settings -> Email to board settings -> Your email address for this board
  6. Send email from gmail to rbreply+x+xxxxxxxxxxx@mydomain.com, Subject "card name", body "some text" as per documentation
  7. Check in thunderbird (right click on Inbox -> Subscribe to show all folders) to show x+xxxxxxxxxxx folders, all e-mails are there.
  8. Check on Restya, but nothing happens
  9. Check logs (nginx, daemon, messages, etcetera) but can't find nothing relevant.
  10. attaching installation log. Using defaults, replaced domain. restyaboard_install.log

Context

I want to send an e-mail and add a card. E-mails are received in thunderbird in plus folders

Your Environment

sridhar391 commented 4 years ago

@dragonauta Can you please set R_DEBUG as true on the config.inc.php file in line 15 on /usr/share/nginx/html/restyaboard/server/php path like https://github.com/RestyaPlatform/board/blob/dev/server/php/config.inc.php#L15 and please send the mail to the board IMAP mail address and wait for 5 mins till the cron reads the mails and after that please check if the cards are created in board and if the cards are not created in board, please attach the Nginx errror log file named error.log file from /var/log/nginx folder path.

dragonauta commented 4 years ago

@sridhar391 sorry for the delay. I enabled R_DEBUG. Rebooted virtual machine just in case. Sent the mail and waited for crontab (I watched syslog and saw cron task execution) but no luck.

/var/log/nginx/access.log show every 10 seconds lines like this: X.X.X.X - - [08/May/2020:18:06:48 -0300] "GET /api/v1/users/1/activities.json?type=all&last_activity_id=83&direction=ASC&token=b25cd64f352729820ebe5b17385c5cc1055153b7&_=1588972008483 HTTP/1.0" 200 97 "https://mydomain.com/restyaboard/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0"

/var/log/nginx/error.log is empty (no other rotated log as it's brand new install)

Any other recommendation?

rrjanbiah commented 4 years ago

@dragonauta

Can you please see if you can directly execute main.sh file found in the shell folder (https://github.com/RestyaPlatform/board/tree/dev/server/php/shell) ? Are you getting any errors?

dragonauta commented 4 years ago
# php -version
PHP 7.2.30-1+0~20200419.40+debian10~1.gbpb1b799 (cli) (built: Apr 19 2020 08:44:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.30-1+0~20200419.40+debian10~1.gbpb1b799, Copyright (c) 1999-2018, by Zend Technologies

So I went to /etc/php/7.2/cli/php.ini and enabled error_reporting (E_ALL) Manually run

# ./main.sh 
2020-05-09 11:15:57 #################################################
successfully acquired lock: /var/www/html/restyaboard/server/php/shell/main_sh.lock

No errors in shell nor nginx/errors.log

Then I went to shell folder and added error_reporting(-1); (under <?php) to main.php, cron_mail.php & imap.php. Also changed error_log /var/log/nginx/error.log warn; to debug Run from command line and also waited for cron, but no trace of error.

One more test: I changed imap server to a wrong value,waited for cron and also run from command line, no error; just the lines above. It's like imap never run in search of mails.

I mentioned in my first post, that I used diagnose.php and saw imap is in orange.

Will try to use xdebug to see what's going on.

rrjanbiah commented 4 years ago

@dragonauta

If you're a technical person, please try to check if it is really reading emails here https://github.com/RestyaPlatform/board/blob/dev/server/php/shell/imap.php#L43

dragonauta commented 4 years ago

I'm trying to debug with netbeans (it's too late here now) Will try tomorrow.

I'm exploring the code, and I see imap.php is never called or included. is this correct?

# cd /var/ww/html/restyaboard
# grep -R imap.php
nbproject/private/private.xml:            <file>file:/var/www/html/restyaboard/server/php/shell/imap.php</file>
server/php/shell/imap.php:define('IMAP_TEMP_FILE', CACHE_PATH . DS . 'imap.php');
rrjanbiah commented 4 years ago

@dragonauta

It is included in main.php https://github.com/RestyaPlatform/board/blob/dev/server/php/shell/main.php through glob iteration

dragonauta commented 4 years ago

Found it! I'm not a PHP expert... heck! even I'm not consider myself a programmer, actually I suck. But I used fwrite to print out on every block.

Problem is that line 40 look for UNSEEN emails just on INBOX, but emails actually goes to folders (i.e. 3+7XXXXX; 4+5XXXXXXX) and not to inbox.

I manually copied those mails to inbox, and voilà, it worked. Cards goes to respective boards and mails gets the SEEN flag

rrjanbiah commented 4 years ago

@dragonauta

Glad to know that it finally worked. Probably you might have set some filters that are moving files to folders.

dragonauta commented 4 years ago

I changed my hosting to not create folder (all emails lands on inbox now). Tested again but it's not working. Only works if I change from >= to <= in line 29 if (round((strtotime('now') - $_imap_time_trace) / 60) >= 30) {

help me understand that line... runs every 30 minutes?

dragonauta commented 4 years ago

help me understand that line... runs every 30 minutes?

Answering myself... yeah... I waited and worked. Thank you all.