uvdesk / community-skeleton

UVdesk Opensource Community Helpdesk Project built for all to make a Full Ticketing Support System along with many more other features.
https://www.uvdesk.com
Open Software License 3.0
8.96k stars 463 forks source link

Need to implement a workflow that alert if any issue with sending email occurs #401

Closed PeopleInside closed 3 years ago

PeopleInside commented 3 years ago

Bug report

Description

There are some cases where UVdesk will be not able to send email notification to operators and to customers. In this event the user or the operator will get always a green success message from the interface that will they think the ticket was notified to operators or the operator reply was sent to the customer but this is not happening.

Tickets should still created, replies to ticket should be added to the system but a warning message should alert the user or the operator that, if the system has recorded the message, some errors occurs with the sending of emails.

Preconditions

Stable Release v1.0.13

Steps to reproduce

I experienced this issue the first time when on my VPS I was having issue with the OpenSSL certificate that was no more valid, this cause to all my PHP application on the server to be unable to send emails.

Usually this issue give an error to the user that is unable to contact me. In UVdesk the user will see a success ticket creation or the operator will see a success reply added to the ticket but no warning will be showed to inform that an error occur while sending the email notification.

This particular case maybe hard to reproduce or you need invalidate the OpenSSL certificate to test, something maybe not suggested.

Another case where this issue can happen is after an UVdesk upgrading where you forget to replace the configuration files from the old backup as in this issue: https://github.com/uvdesk/community-skeleton/issues/355#issuecomment-832002613

Following the step mentioned by @vaishaliwebkul will cause email to stop working because commands replace completely the configurations files so in UVdesk will be no more a valid email address configured.

In this particular case user and operator will still see a green confirmation message of replies or ticket added without notice was not possible to send the notification email. This should be changed with a warning. It's important to allow the reply or the ticket to be added in the UI but just inform, with maybe a second alert notification or a different message that while the recording was done successfully some errors occurs in sending emails.

Expected result

Maybe under the green message another orange message should inform the user some email error occurs. If is not possible to add a second error below the green one maybe the successful message should be different: orange instead of green and should alert while ticket or reply has been recorded in the system, was not possible send emails notification due to errors.

Actual result

No email error are showed so operator and customer think all works in the case the email system is down for some reason. This should be improved, changed to give a more trustable and better experience.

I was previously opened an issue here, closed because I was scared to create an error that stop the ticket or the reply to be created but thinking more this should be avoided and a simple error warning, under the success message or simply a different success message should be showed in the case of email errors.

papnoisanjeev commented 3 years ago

@PeopleInside

Success message comes for successfully creating a ticket and showing multiple flash message makes confusion.

So adding below procedure to debug if anyone facing problem while sending emails. It will show you error while sending emails.

Locate the file vendor->uvdesk->core-framework->Services->EmailService.php

Open the EmailService.php reach to sendMail() function.

and dump() the exception as in attached in below images.

image

  image

It will show the error you are facing while sending mails (if adding an agent, creating a ticket etc).

 

Other helpful link:

https://forums.uvdesk.com/topic/1870/how-to-debug-the-error

PeopleInside commented 3 years ago

Umh thanks. Show multiple flash message can confuse but is good to show only green message to successful ticket or reply when no alert email is sent to the agent or to the customer. What is more bad?

Is more bad confuse user with multiple flash message if an error occur while sending email or just show a green nice message when replies will be not read by anyone as is not sent by email?

The strong suggested will show sensible debug info to the user? Will be for sure an edit I need to do in the code for every time UVdesk is updated and as default UV desk will still show all ok when is not.

I don't think this temporary fix will resolve what IM reporting.

PeopleInside commented 3 years ago

@papnoisanjeev I have inserted the string suggested by you than cleared cache than i stopped Exim and Dovecot on my server and I tried to use the contact form page to create new ticket simulating a customer. No error was showed, ticket was created successfully without error.

Are you maybe confusing the fact I'm on prod mode and not develop mode so no error are showed? I done a test with live helper chat send email testing page and there error was showed: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

So UVdesk still not inform users or operators when an issue occur by email. You should / must be also secure when you suggest a fix, testing and be sure works.. remembering the normal situation is not to be in debug mode but prod mode.

papnoisanjeev commented 3 years ago

@PeopleInside

Add same line dump($e->getMessage()); die; in three places. First here, second here, third here.

If there is any issue while sending email then you will defiantly see error by above solution.

Finally create a ticket or any other action in which a email notification comes.

Whenever you want to debug a error you need to place your project in dev mode to see actual error. Else in prod mode it will just show you a error page without any information.

PeopleInside commented 3 years ago

Hi, I tested your "solution" and is not fully working. Adding the line you say forbid the creation of the ticket and is not what I want and what I'm suggesting.

I'm loosing a bit my time. Adding the three row and stopping dovecot and exim than try to create a ticket show an error and ticket is not created. Not create ticket is not the result I suggest, ticket should be created but a friendly message should inform user or operator that an error occur while send email notification.

Maybe you can implement a different confirmation message that say ticket has been created but was not possible sending email, and the color of this confirmation message can be yellow. This yellow confirmation message is showed if system get errors on sending email but ticket should be created!

What you suggest to do is forbid ticket if a sending email error occur, is not what I was suggesting.

Also I notice that if I run php bin/console c:c from root, the prod folder change his permission from user to root. Why this? Today when I edited the three row and try to clean cache all files and folder under prod was with root permission and was giving error:

php bin/console c:c

11:14:11 ERROR     [console] Error thrown while running command "'c:c'". Message: "Unable to write in the "uvdesk/var/cache/prod" directory" ["exception" => Symfony\Component\Console\Exception\RuntimeException^ { …},"command" => "'c:c'","message" => "Unable to write in the "/uvdesk/var/cache/prod" directory"]

  Unable to write in the "uvdesk/var/cache/prod"
   directory

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
papnoisanjeev commented 3 years ago

@PeopleInside

What you suggest to do is forbid ticket if a sending email error occur, is not what I was suggesting.

We are not adding that three line which we have suggested it was just for debugging purpose only if anybody facing problem while sending emails. We will surely add a message for the same and ticket will create always without any issue (regardless of email part).

Also I notice that if I run php bin/console c:c from root, the prod folder change his permission from user to root. Why this?

There is no connection between these updates you have done and error while clearing cache. It is just permission issue and please provide required permission.

PeopleInside commented 3 years ago

We will surely add a message for the same and ticket will create always without any issue (regardless of email part).

Ok so I need keep this open and wait an improvement. I don't need diagnostic but error in any case where server can be broken temporarily. Thanks.

papnoisanjeev commented 3 years ago

@PeopleInside

Yes sure, we will update for the same and it will also add with next release.