vojtasvoboda / oc-errorlogger-plugin

ErrorLogger plugin for October CMS
MIT License
15 stars 7 forks source link

Email notification seems to not work #5

Open pmhou opened 7 years ago

pmhou commented 7 years ago

I have my mailer settings set up and working with Mailgun credentials.

I've set logging level to 100 and unchecked 'Disable when debug' and triggered an error with Log::error('Test');

The error is written to the system log file and appears in the Event Log but no email sent.

vojtasvoboda commented 7 years ago

I'm sorry to hear you have a problem with Error Logger plugin. I just cloned fresh OctoberCMS master branch, keep config files with default values, install Error Logger plugin and set plugin like this:

snimek obrazovky 2017-02-27 v 21 18 50

Then fire a error in template:

snimek obrazovky 2017-02-27 v 21 16 49

And got mail to my mailbox in a few seconds:

snimek obrazovky 2017-02-27 v 21 21 24

I recommend you try to send Log::error with PHP mail method, to eliminate Mailgun misconfiguration. Also check mail.pretend config value to be false.

pmhou commented 7 years ago

My Mailgun settings are definitely correct as I can trigger emails using the Mail facade no problem. I have also changed my settings to use PHP Mail, Log file and SMTP - all of which successfully send emails, just not when an error is triggered.

I can confirm mail.pretend is set to false.

vojtasvoboda commented 7 years ago

Are you using some other Loggers? Slack, Syslog, New Relic, Sentry, Bugsnag? Maybe some other Logger "steals" the logged data.

vojtasvoboda commented 7 years ago

Now I tried a combination of Mail logger and Slack logger and both works well:

logger

So I don't know where could be your problem. I can't reproduce your issue. Could you please put your project somewhere to the Git, where I can try it? Let me know directly to email please. Thanks.

pmhou commented 7 years ago

I've just had the opportunity to look at this again. It appears that your plugin only uses PHP's mail() method to send email. Is that correct?

vojtasvoboda commented 7 years ago

Yes, you are right. This plugin uses Monolog/NativeMailerHandler, which uses plain mail() function to send e-mails:

https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/NativeMailerHandler.php#L140

pmhou commented 7 years ago

I didn't realise that was the case when I posted this issue. Native mail is not set up by default with Laravel Homestead which was causing the issue. I assumed whichever mail method specified in the October settings would be used.

vojtasvoboda commented 7 years ago

Me niether. I also thought that NativeMailerHandler using Laravel Mail function, so you can configure mail/smtp etc.

I have to update documentation.

LukeTowers commented 6 years ago

@vojtasvoboda do you have any plans to utilize the default mail driver configured for the application to send error messages instead of the built in mail() method? The mail() method in PHP is inherently insecure and potentially vulnerable, in fact SwiftMailer has dropped support for it entirely.

vojtasvoboda commented 6 years ago

@LukeTowers this plugin only register Monolog\Handler\NativeMailerHandler to the OctoberCMS. So all the magic is in this handler and there is no way how to inject own mail sender or configure sending.

So I've prepared integration of Monolog\Handler\SwiftMailerHandler, which using OctoberCMS Swift mailer: https://github.com/vojtasvoboda/oc-errorlogger-plugin/pull/7

I tried it now with Mailtrap.io configured in OctoberCMS Mail settings and seems to works. Could you please test it? Thanks a lot

@pmhou Hi Pete, there is new Swift Mailer handler, so now you can use OctoberCMS mail configuration. Could you please test it? Thanks a lot