Developer forum

Forum » Development » EmailHandler logging emails

EmailHandler logging emails

Theis Nickelsen
Reply

Hi,

I noticed that the EmailHandler is logging emails. Log example:

Path: \System\Log\EmailHandler

Log entry:

[01-05-2018 10:46:40]: Mail sent successfully using Pickup Directory Service.
[01-05-2018 10:46:40]: Recipients: ---------------@------------.dk 
[01-05-2018 10:46:40]: CC Recipients: ---------------@------------.dk 
[01-05-2018 10:46:40]: BCC Recipients: ---------------@------------.dk 

DynamicWeb version: 9.3.4

As per GDPR this is not desired. Is there any way to turn this off?

Theis


Replies

 
Nicolai Pedersen
Reply

Yes, upgrade and Dynamicweb will not do that anymore... #OldSoftwareIsOld

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Theis,

You're using an old version of Dynamicweb that doesn't have any GDPR compatibility, which is why you're running into this issue, and you'll have multiple other issues regarding GDPR on this version.

Optimally, you should upgrade your solution to a newer version of Dynamicweb. However, I understand that it might not be possible for you to do that at the moment, so you can install version 3.0.4 of Dynamicweb.Mailing. This will obfuscate the emails in the log, and it's possible to disable the log altogether by adding a setting in the Global Settings file:

/Globalsettings/System/MailServer/DoNotLog

And set it to true

- Jeppe

 
Theis Nickelsen
Reply

Hi Jeppe,

Would it be possible to get version 3.0.4 sent pr. email? I can only find 3.0.1 and 3.0.5 in your archive. Or would 3.0.5 work with DynamicWeb v 9.3.4 as well?

Thanks.

Theis

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Theis,

I'm not sure which archive you're referring to, but I think it's easiest if you download it directly from NuGet: https://www.nuget.org/packages/Dynamicweb.Mailing/3.0.4 :)

- Jeppe

 
Theis Nickelsen
Reply

Hi Jeppe,

Thanks. Although I get an error if I replace Dynamicweb.Mailing with this and try to send an email from the backend.

Theis 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Theis,

It's difficult for me to assist if I don't know which error you're getting. Could you post the stacktrace and/or a screenshot?

- Jeppe

 
Theis Nickelsen
Reply

Hi Jeppe,

There are no details in the error. See attached.

Theis

Capture.PNG
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

If you haven't turned off logging completely, then you should be able to see the error in the log file.

Otherwise, you can post a link to the solution so I can take a look for myself. If you don't want to post the url here, you can send it to me. You can find my email address by mousing over the name under my profile picture.

- Jeppe

 
Theis Nickelsen
Reply

Where are the logs located? Can't seem to find them

Theis

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

It's the same logs that started this thread.

 
Theis Nickelsen
Reply

Those logs does not contain any log entries of failed attempts from today or log entries of trying to send to the email address specified

Theis

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Did you turn off logging as mentioned earlier? If yes, then the log will not contain new entries.

Where (module/app) are you getting the error message?

 
Theis Nickelsen
Reply

Logging is not turned off.

I'm getting the error message when sending a test email from Marketing->Email Marketing->Create new email

Theis

 
Nicolai Pedersen
Reply

I do not think the 3.* version of mailing is compatible with 9.3 if you only upgraded the mailing package?

 
Theis Nickelsen
Reply

Yes I only updated the Mailing package.

Theis

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

I've tried to get this working and this is the conclusion.

In order to get it working on 9.3.x, you'd have to update Dynamicweb.Mailing, Dynamicweb.Data and Dynamicweb.Logging. Then you'd have to change the database schema to match the event logging of 9.6.

So, I guess there are four options where three of them are viable:

  1. Upgrade to at least 9.6 (preferably 9.7) and get the GDPR features out of the box
  2. Leave the solution at 9.3.4 and be okay with the way it handles email logging
  3. Create a piece of custom code that injects itself in the mailing process and makes sure that logging is disabled
  4. Try and get a customized 9.3.4 to work

At this point, I consider option 4 to be the non-viable option.

Option 1 is the most desirable solution, followed by option 2. Option 3 can work but it will disable the logging completely unless you turn on "Save to disk".

The subscriber for option 3 could look something like this:

using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Mailing;
using System;
using System.Net.Mail;

namespace EmailProxy
{
    [Subscribe(Dynamicweb.Mailing.Notifications.EmailNotifications.OnBeforeEmailSend)]
    public class EmailProxySubscriber : NotificationSubscriber
    {
        [ThreadStatic]
        private static MailMessage _message;

        public override void OnNotify(string notification, NotificationArgs args)
        {
            var emailArgs = args as Dynamicweb.Mailing.Notifications.EmailSendNotificationArgs;

            // Check if the current email is the same as the one we're sending below - if so, return
            if (emailArgs.Message == _message)
                return;

            try
            {
                _message = emailArgs.Message;
                var wasSent = EmailHandler.Send(emailArgs.Message, logging: false, throwException: true);
                emailArgs.IsHandled = true;
                emailArgs.WasSent = wasSent;
            }
            catch
            {
                // TODO: Do something maybe
            }
        }
    }
}

NB: This has only been tested with a single recipient, so you should do your own tests on larger batches.

- Jeppe

 

You must be logged in to post in the forum