timeoff-management / timeoff-management-application

Simple yet powerful absence management software for small and medium size business (community edition)
https://TimeOff.Management
MIT License
951 stars 588 forks source link

NO EMAILS! #142

Closed kimaniidaniel closed 7 years ago

kimaniidaniel commented 7 years ago

I have configured the my SMTP email account settings in apps.json file and have verified that the email info works (by logging into webmail). Yet I DONOT get emails for the requests, revokes, etc. Furthermore every time I log a request, accept, revoke etc, I get a Red alert telling me "Failed to Reject" (or the specified action) although IT DOES complete the action. So I'm confused but I believe this is because of the email probably failing. Any thoughts or help on this would be appreciated.

Thank you

vpp commented 7 years ago

Hi @kimaniidaniel,

Can you send parts of the application logs that are produced when you perform any action that triggers email, such as requesting a time off.

You can email it to pavlo@timeoff.management if you like.

Thanks

On 13 Apr 2017, at 16:55, kimaniidaniel notifications@github.com wrote:

I have configured the my SMTP email account settings in apps.json file and have verified that the email info works (by logging into webmail). Yet I DONOT get emails for the requests, revokes, etc. Furthermore every time I log a request, accept, revoke etc, I get a Red alert telling me "Failed to Reject" (or the specified action) although IT DOES complete the action. So I'm confused but I believe this is because of the email probably failing. Any thoughts or help on this would be appreciated.

Thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

kimaniidaniel commented 7 years ago

Might be a dumb question but where is the application log? Thank you for you quick response.

vpp commented 7 years ago

If you start the app with

non start

Then it is just in the same terminal

Sent from my iPhone

On 13 Apr 2017, at 17:38, kimaniidaniel notifications@github.com wrote:

Might be a dumb question but where is the application log?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

kimaniidaniel commented 7 years ago

Sent via email

vpp commented 7 years ago

@kimaniidaniel, I do not have experience running the app on the windows. But recently I had conversation with person who also experienced slightly different issues to your ones and we googled out following FoF thread http://stackoverflow.com/questions/34393147/nodejs-nodemailer-iis-smtp-virtual-server and additional that proved helpful for him.

Here is relevant part:

Hello Pavlo,

Thanks for your help. What I did to make it work was to remove completely the auth part. Now I'm looking for to modify the mail template sent to the users.

Thank you again. Keep going on the dev, this is a great app man, which i think will make all users happy to not deal with excel sheet anymore.

On Wed, Jan 18, 2017 at 6:42 PM, Pavlo pavlo@timeoff.management wrote: Google suggests this post as one possible solution:

http://stackoverflow.com/questions/34393147/nodejs-nodemailer-iis-smtp-virtual-server

Time off management indeed uses nodemailer under the hood.

Consider updating email_transporter section in https://github.com/timeoff-management/application/blob/master/config/app.json#L5 to match the advise given in SoF link above.

Or tweak the code around this line https://github.com/timeoff-management/application/blob/master/lib/email.js#L69 to ensure the config is similar to advised one.

Thanks Pavlo

vpp commented 7 years ago

As in example of your logs the error is

An error occurred when attempting to reject leave request 12 by user 1 Error: Error: certificate has expired

Consider adding

secure: false,

to config as per SoF article from previous comment.

kimaniidaniel commented 7 years ago

I tried the secure: false and it was still failing so after digging deeper into nodemailer SMTP doc (https://nodemailer.com/smtp/) I decided to try ignoreTLS: false also and that did the trick. so the full email config (with redacted sensitive info):

"email_transporter" : { "host": "****", "port": 25, "secure" : false, "ignoreTLS": true, "auth": { "user" : "***", "pass" : "**" } },

kimaniidaniel commented 7 years ago

However!... the emails come with the body html in the subject of the email. How do I fix that, is there a template somewhere i can modify?

vpp commented 7 years ago

Thank you for sharing the example of config, that would be very useful for other users.

vpp commented 7 years ago

regarding emails templates have a look here https://github.com/timeoff-management/application/tree/master/views/email

vpp commented 7 years ago

can you give more details about "body html in subject" as it sounds like bug (we recently updated emails to be html based so looks like that has an issue)?

kimaniidaniel commented 7 years ago

Here are some screenshots (3), notice the subject has the body of the email and the body has nothing.

[image: Inline image 3]

[image: Inline image 1] [image: Inline image 2]


Kimanii G. Daniel MSc MCP www.kimaniidaniel.com m: 473.534.4003

Live - Love - Learn

On Thu, Apr 13, 2017 at 1:45 PM, Pavlo notifications@github.com wrote:

can you give more details about "body html in subject" as it sounds like bug (we recently updated emails to be html based so looks like that has an issue)?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/timeoff-management/application/issues/142#issuecomment-293972219, or mute the thread https://github.com/notifications/unsubscribe-auth/AHSzjAX4RzJwIuK6HxutYvj5GUXa-UGRks5rvl8igaJpZM4M84gA .

vpp commented 7 years ago

Unfortunately screenshots were not attached... maybe try to send them to email?

One more thing: do emails sent by installation at http://app.timeoff.management have the same issue?

Sent from my iPhone

On 13 Apr 2017, at 19:11, kimaniidaniel notifications@github.com wrote:

Here are some screenshots (3), notice the subject has the body of the email and the body has nothing.

[image: Inline image 3]

[image: Inline image 1] [image: Inline image 2]


Kimanii G. Daniel MSc MCP www.kimaniidaniel.com m: 473.534.4003

Live - Love - Learn

On Thu, Apr 13, 2017 at 1:45 PM, Pavlo notifications@github.com wrote:

can you give more details about "body html in subject" as it sounds like bug (we recently updated emails to be html based so looks like that has an issue)?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/timeoff-management/application/issues/142#issuecomment-293972219, or mute the thread https://github.com/notifications/unsubscribe-auth/AHSzjAX4RzJwIuK6HxutYvj5GUXa-UGRks5rvl8igaJpZM4M84gA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

kimaniidaniel commented 7 years ago

Changing the regex on line 58 of lib/email.js to be more OS agnostic by introducing conditional regex of [\r\n] worked for me. I would like to know if it also works on *nix systems.

var subject_and_body = text.split(/\n=====\n/); to var subject_and_body = text.split(/[\r\n]=====[\r\n]/);

vpp commented 7 years ago

@kimaniidaniel can you please check if this regex works on windows:

var subject_and_body = text.split(/\r?\n=====\r?\n/);

Sent from my iPhone

On 13 Apr 2017, at 22:09, kimaniidaniel notifications@github.com wrote:

var subject_and_body = text.split(/[\r\n]=====[\r\n]/);

vpp commented 7 years ago

Got reply from @kimaniidaniel that suggested regex works well on Windows.

Pushed the patch into master.