Web Connection
Apply newer SMTP properties for SendAdminEmail() and SendErrorEmail() functions
Gravatar is a globally recognized avatar based on your email address. Apply newer SMTP properties for SendAdminEmail() and SendErrorEmail() functions
  Mike McDonald
  All
  Jan 9, 2019 @ 04:33pm

Rick -

In wwProcess.prg there are functions for SendAdminEmail() and SendErrorEmail(). One forces wwSMTP.nMailMode to 0 and the other forces nMailMode to 2.

I suggest adding a nAdminMailMode property to the wwServerConfig class, and then use that property in the two wwProcess email functions, so they will pick up the value from the user's INI file.

The same scenario might also apply for the wwSMTP.nServerPort value.

Also in the default (projectname)Main.prg which is generated by the Management Console for a new project, the Process() method will optionally attempt to send an admin email for any "Unhandled Request".

That code creates a separate wwSMTP object, but doesn't set several of the more recent config properties (cAdminMailUsername, cAdminMailPassword or lAdminMailUseSSL) or the nMailMode or nServerPort wwSMTP properties. Maybe this code block could just call Server.SendAdminEmail() instead?

- Mike McDonald

Gravatar is a globally recognized avatar based on your email address. re: Apply newer SMTP properties for SendAdminEmail() and SendErrorEmail() functions
  Rick Strahl
  Mike McDonald
  Jan 9, 2019 @ 06:55pm

Well the nMailMode should be 0 - .NET is now required by Web Connection for other things, so requiring it no longer the issue that it once was so the mail mode can be set to 0 as a fixed value. Done - thanks for spotting the inconsistency.

The Mail Server Port can be specified on the mail server string like this in the INI or oServer.oConfig.cAdminMailServer:

AdminMailServer = "smtp.myserver.com:587"

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Apply newer SMTP properties for SendAdminEmail() and SendErrorEmail() functions
  Mike McDonald
  Rick Strahl
  Mar 4, 2019 @ 11:28am

Rick -

Well the nMailMode should be 0 - .NET is now required by Web Connection for other things, so requiring it no longer the issue that it once was so the mail mode can be set to 0 as a fixed value.

The default value for nMailMode in wwSMTP.prg is 2 (classic), so maybe that should be changed to 0 since .NET mode is now required?

The Mail Server Port can be specified on the mail server string like this in the INI or oServer.oConfig.cAdminMailServer:
AdminMailServer = "smtp.myserver.com:587"

I set the port number with the server name, but I still need to subclass wwProcess::SendErrorEmail() because the wwSMTP property for lUseSSL doesn't get set in there, and Gmail returns a message about requiring a secure connection if that property is not .T.

The default project INI template includes a config setting for Adminmailusessl but that isn't applied in SendErrorEmail(), although it is used in SendAdminEmail().

- Mike McDonald

Gravatar is a globally recognized avatar based on your email address. re: Apply newer SMTP properties for SendAdminEmail() and SendErrorEmail() functions
  Rick Strahl
  Mike McDonald
  Mar 4, 2019 @ 12:19pm

I leave nMailMode = 2 because wwSmtp is also part of Client Tools, and using 2 doesn't have any depedencies beyond wwipstuff.dll where .NET mode does have extra dependencies and it works fine for internal mailing for testing and inter-network services. So that won't change in the near future.

I've added the relevant code for the wwServer::Process method that sends admin email on routing failures.

I think that code should probably be refactored to a wwServer::SendAdminEmail() method that is called for all email operations including the one from wwProcess (it can just forward to that) so that code is all configured and accessed in one place. Right now no admin emails are sent for example, on startup failures although that does get logged.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Apply newer SMTP properties for SendAdminEmail() and SendErrorEmail() functions
  Rick Strahl
  Mike McDonald
  Mar 4, 2019 @ 12:58pm

So I've consolidated all the SendMail operations to call back into a new wwServer::SendAdminEmail() method that is used to forward all other email tasks to, so there's a single point of configuration/email handling.

There should be no behavior changes to existing code, just the plumbing is different.

The new method uses .NET Mode and the lAdminUseSsl configuration flag.

+++ Rick ---

© 1996-2019