InstructorSite / Global Settings / SMTP Settings / App Settings Overrides

SMTP settings can be overridden in the <appSettings> section of the web.config or app.config for UniversitySite. When these overrides are turned on, UniversitySite will use the settings that are specified in the config file rather than those specified in the database.

This is most useful in an environment where you might be running multiple instances or databases of UniversitySite on the same computer. This will allow you to setup one config file with the desired SMTP settings for this computer and UniversitySite will use them instead of whatever SMTP settings are specified the database.

Here is a list of the SMTP settings that can be specified in the config file:

  •  <add key="SMTP_UseAppSettingsInsteadOfDatabaseSettings" value="true" />
    • Set this to true if you want to override the database settings with the app settings in the config file or false to force use of the database settings.
  • <add key="SMTP_Server" value="smtpserver" />
    • Set this to the name or address of the SMTP server responsible for delivering emails.
  • <add key="SMTP_UserName" value="username" />
    • Set this to the username required for login to the SMTP server, if any or leave blank
  • <add key="SMTP_Password" value="password" />
    • Set this to the password required for login to the SMTP server, if any or leave blank
  • <add key="SMTP_Port" value="25" />
    • Set this to the port number required by the SMTP server
  • <add key="SMTP_Ssl" value="false" />
    • Set this to true if the connection to the SMTP server requires SSL or set to false

For developers this can come in very handy since you can define SMTP settings in the web.config or app.config that will force email to be sent to Papercut instead of being sent to a real SMTP server. Here's my app.config settings for forcing all databases I use to always send emails to Papercut:

  •          <add key="SMTP_UseAppSettingsInsteadOfDatabaseSettings" value="true" />
  •          <add key="SMTP_Server" value="localhost" />
  •          <add key="SMTP_UserName" value="" />
  •          <add key="SMTP_Password" value="" />
  •          <add key="SMTP_Port" value="587" />
  •          <add key="SMTP_Ssl" value="false" />

This can also be useful in a scenario where multiple instances of UniversitySite are running on the same server. In this case, you could specify the desired SMTP override settings in the web.config file in your web root folder (for example: C:\inetpub\wwwroot) and all sites hosted on that computer will now use those SMTP settings that have been overridden in that config file. We’ll call this the “global appsettings override”. Perhaps you’d want to force all instances of UniversitySite running on the UniversitySite server to send all email to the local SMTP server on that server instead of using the database settings in each instance, you could add something like this to the <appSettings> section of the web.config in C:\inetpub\wwwroot (or wherever your webroot is located):

  •          <add key="SMTP_UseAppSettingsInsteadOfDatabaseSettings" value="true" />
  •          <add key="SMTP_Server" value="localhost" />
  •          <add key="SMTP_UserName" value="" />
  •          <add key="SMTP_Password" value="" />
  •          <add key="SMTP_Port" value="25" />
  •          <add key="SMTP_Ssl" value="false" />

Assuming we did that right, every instance of UniversitySite running on that server is now sending email via the local SMTP server. Now what if we wanted one of those instances to use the database settings instead of the SMTP settings specified in the “global appsettings override”? In that case, we just need to add one setting to that instance’s app.config and set it to “false” as follows:

  •          <add key="SMTP_UseAppSettingsInsteadOfDatabaseSettings" value="false" />

Additionally, we could decide there is an instance that we don’t want to use the SMTP settings in the database, but we also don’t want to use the “global appsettings override” either. We could simply add all the SMTP settings to the app.config file for that instance as follows:

  •          <add key="SMTP_UseAppSettingsInsteadOfDatabaseSettings" value="true" />
  •          <add key="SMTP_Server" value="localhost" />
  •          <add key="SMTP_UserName" value="" />
  •          <add key="SMTP_Password" value="" />
  •          <add key="SMTP_Port" value="587" />
  •          <add key="SMTP_Ssl" value="false" />

Now we’d have all instances of UniversitySite on this computer using the “global appsettings override” settings for SMTP except for the one that uses its own database settings instead and another that uses its own <appSettings> in its app.config file instead.

Still need help? Contact Us Contact Us