Hi,
I'm running DNN 4.3 in an environment where e-mail through SMTP is not allowed. We are a post-secondary school, and our Information Systems department just refuses to allow any SMTP support in internal websites; all mail is to be run through Exchange Server. Therefore, we cannot do any Host level settings to set meaningful SMTP values.
This causes problems in every day administrative tasks in the DNN portal for any part that supports DNN mail services.
For example, every time we work with users (adding to roles, for example), the "Send Notification" check box is always set. If we don't have SMTP available in our environment, then we always have to manually un-check the box before we do anything with adding/removing roles for a user. It would be better if the DNN portal could tell that SMTP is not "available", and uncheck/disable the checkbox for us.
In this particular example, the check could be done on line 175 of the BindData() method of the SecurityRoles class (Namespace DotNetNuke.Modules.Admin.Security) to ensure that SMTP is indeed available (or used). If e-mailing is not supported in the host configuration, then the chkNotify checkbox should be set to un-checked and disabled.
I admit that I've only been diving into the whole DotNetNuke.Services.Mail for a *very* short time (only this morning, in fact), and from the little I've read in the code, there seems to be an assumption that *some* kind of e-mail settings will be present:
In lines 224 to 238 of the class DotNetNuke.Services.Mail.Mail, there is a check to see if the SMTP server string is empty, in order to set the smtpClient host, port, and credentials to meaningful values. But from there it just dives right into attempting to send the e-mail.
From what I read about the SmtpClient class in the .NET framework, the default constructor (which is used in line 222 to create the smtpClient object) will try to fill the Host, Credentials, and Port information from the web.config or the machine.config files. But if this information is not present (the mailSettings element in the .config), then the attempt to send the e-mail is definately set up for failure (resulting in the exception being caught in lines 243ff of the SendMail method of the Mail class).
Perhaps there should be a Host Setting that allows SMTP to be disabled. Other parts of the DNN framework could check this setting before even attempting any mail activities.
Just a thought. I know I could implement this myself by changing the core, but I loathe to do such a thing. It would be nicer if it was already built into the core. Thoughts, anyone?