digitalfondue / lavagna

Lavagna: issue tracker/project management tool
http://lavagna.io
GNU General Public License v3.0
636 stars 110 forks source link

Issues with the mail ticket feature #83

Closed fernandodiacenco closed 7 years ago

fernandodiacenco commented 7 years ago

Hi,

First of all, thanks for this feature!

So, I tried it on m4, m5 and now i'm on 1.1-M6, here is what happens:

I configure everything, the email account can send and receive email, I configure an alias, everything seems ok

Lets say I have the account called tasks@company, I send and email to the "test@company" alias, that is configured to create a card in the "Test" board, the email is received on the account, and checking the webmail after a few moments the email is marked as read (Probably by lavagna)

But the card is never created, i'm not sure where lies the problem, I tried a few different configurations without luck

So i'm here to ask, its is possible to have a new button, like "test connection" or "receive email now" or something on M7? Thanks.

syjer commented 7 years ago

Hi @fernandodiacenco ,

thank you for the feedback. Yes, adding a way to understand what is going on is clearly a must.

For debugging your problem:

fernandodiacenco commented 7 years ago

Hi, thanks for answering

I'm using Lavagna self contained with the prod variable for testing, the email protocol is POPS

I tried reinstalling everything, same thing happens: the webmail reports the email as read but there is no card, no other clients are reading this email box

I've attached the console text, I hope this helps because I didn't find any other logs yet.

lavagna_console.txt

Thanks!

syjer commented 7 years ago

hi @fernandodiacenco , thank you for the log :).

The log contain the error:

08:55:06.475 [ThreadPoolTaskScheduler-1] ERROR io.lavagna.config.PersistenceAndServiceConfig$1 - error while handling job
java.lang.NullPointerException: null
        at io.lavagna.service.MailTicketService.checkNew(MailTicketService.java:144) ~[classes/:?]

The code that fail is:

for (int i = 0; i < messages.length; i++) {
                    MimeMessage message = (MimeMessage) messages[i];
                    if (!message.getReceivedDate().after(entry.getLastChecked())) {
                        continue;
                    } else {
                        updateLastChecked = message.getReceivedDate().after(updateLastChecked) ?
                            message.getReceivedDate() :
                            updateLastChecked;
                    }

looks like that the message.getReceivedDate() is returning a null value.

It seems we have a case which we don't handle correctly, we will do a fix.

syjer commented 7 years ago

as described in https://stackoverflow.com/a/6163299 , looks like pop3 does not provide the receivedDate. @fernandodiacenco , as a first workaround, could you try, if possible, to use imap?

(in the meantime we will try to provide a fix)

syjer commented 7 years ago

@fernandodiacenco , I've uploaded a snapshot so you can try the fix that I've committed.

You can download it at https://oss.sonatype.org/content/repositories/snapshots/io/lavagna/lavagna/1.1-M7-SNAPSHOT/lavagna-1.1-M7-20170803.125138-2-distribution.zip

fernandodiacenco commented 7 years ago

Tried the new snapshot, the email is marked as read, still no card created, console shows this:

10:30:06.067 [ThreadPoolTaskScheduler-1] ERROR io.lavagna.service.MailTicketService - for ticket mail config id 0: was not able to fetch the "receive date" for email sent by fernando.xavier@confitec.com.br

I will try IMAPS as soon as i can and return with the results, thanks!

syjer commented 7 years ago

@fernandodiacenco , thanks for the check, well, looks like that POP3 does not give enough informations... I guess that we will remove and leave only the IMAP support.

fernandodiacenco commented 7 years ago

Hmm I reinstalled to make sure configuration wasn't the problem, and tried IMAPS a few times

Id did not mark the email as read, the log shows:

11:33:05.099 [ThreadPoolTaskScheduler-1] ERROR io.lavagna.service.MailTicketService - could not retrieve messages for ticket mail config id: 0

Unfortunately it does not give me more details, I wish to know if the error is because of some weird uncommon particularity of my email provider or something else.

syjer commented 7 years ago

@fernandodiacenco , I'll check what we can do to improve the diagnostic/logging so we can resolve your issue :)

syjer commented 7 years ago

@fernandodiacenco , I've added additional logging, it will print the full exception, can you try with the latest SNAPSHOT release https://oss.sonatype.org/content/repositories/snapshots/io/lavagna/lavagna/1.1-M7-SNAPSHOT/lavagna-1.1-M7-20170805.133028-3-distribution.zip thanks :+1:

fernandodiacenco commented 7 years ago

I tested it, the email is marked as read using both POPS and IMAPS but no card is created

Starting jetty server 9.2.22.v20170606 Server is listening at 0.0.0.0/0.0.0.0:8080 09:12:26.663 [main] WARN io.lavagna.common.LavagnaEnvironment - Property datasource.password is not set, using default value: 09:12:26.670 [main] INFO io.lavagna.common.LavagnaEnvironment - For property datasource.dialect, the value is: HSQLDB 09:12:26.670 [main] INFO io.lavagna.common.LavagnaEnvironment - For property datasource.url, the value is: jdbc:hsqldb:mem:lavagna 09:12:26.670 [main] INFO io.lavagna.common.LavagnaEnvironment - For property datasource.username, the value is: sa 09:12:26.671 [main] INFO io.lavagna.common.LavagnaEnvironment - For property spring.profiles.active, the value is: prod SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/tmp/jetty-0.0.0.0-8080-lavagna-jetty-console.war-_-any-1484549344209463155.dir/webapp/WEB-INF/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/srv/lavagna-1.1-M7-SNAPSHOT/lavagna/lavagna-jetty-console.war!/WEB-INF/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

To make sure, I deleted the email account and created another with another address, and another alias, same thing happens

If I configure the wrong password, it gives and exception (auth failed) and the email, of course is not marked as read

So, apparently Lavagna is accessing the email box and reading its contents, perhaps the problem lies somewhere after that?

I thought about trying with a gmail account, but I can't create an alias to test with it.

auth failed when using wrong password.txt

syjer commented 7 years ago

@fernandodiacenco , thanks for checking, so the configuration for connecting to the mailbox is correct.

Most likely it's a problem in the configuration of the alias/board setting. We will add some additional log so we can trace it better.

syjer commented 7 years ago

As an example of configuration of the alias:

screenshot from 2017-08-07 15-06-16

fernandodiacenco commented 7 years ago

The only difference in my config was that I checked "send email as alias", but its not working without it either

image

image

syjer commented 7 years ago

@fernandodiacenco , thanks for the feedback. We will add some additional logging. It's really strange as we just tested on our instance and it's working.

syjer commented 7 years ago

One possible case is that

private String getDeliveredTo(MimeMessage message) throws MessagingException {
  return message.getHeader("Delivered-To", "");
}

which is used in

String deliveredTo = getDeliveredTo(message);
for (ProjectMailTicket ticketConfig : entry.getEntries()) {
  if (ticketConfig.getEnabled() && ticketConfig.getAlias().equals(deliveredTo)) {

is not returning the expected value.

Edit: it looks like that the "Delivered-To" header is not even guarantee to contain the correct data: https://stackoverflow.com/a/4743170 .

syjer commented 7 years ago

@fernandodiacenco , I've committed a more general approach for checking the presence of the alias email in the email headers and added more logging, you can try with the following snapshot, https://oss.sonatype.org/content/repositories/snapshots/io/lavagna/lavagna/1.1-M7-SNAPSHOT/lavagna-1.1-M7-20170815.141618-4-distribution.zip .

Thank you :)

fernandodiacenco commented 7 years ago

It worked, and I received the email notification normally

image

Thanks!

syjer commented 7 years ago

.@fernandodiacenco thank you for testing :+1: