# Are the mail settings as given in preferences still programmatically accessible in V 11.2

In versions before 11.2 (and after 9) one could get the current settings as defined in the preferences (Internet & Email -> Mail Settings) with Options[SendMail]. As the options for SendMail have changed, this does now not work anymore. There now are only MailAddressValidation and MailSettings as options, and the latter is meant to hold an association which defines those paramters, but its default value is Automatic and there seems to be no documented way to programmatically access the values that have been set in the preferences.

Does anyone know a possibility to extract those programmatically anyway?

Settings are stored at "ApplicationData\SendMail\Preferences\MailSettings.m" and "ApplicationData\SendMail\Preferences\MailSettingsNew.m" under the $UserBaseDirectory. msp = FileNameJoin[ {$UserBaseDirectory
, "ApplicationData"
, "SendMail"
, "Preferences"
, "MailSettings.m"
}]

Query["MailSettings", "Server"][Get@msp]


We can access the present settings using an undocumented global variable:

ExternalServiceMailSettings$MailSettings (* <| AutoBcc->{},AutoCc->{},EncryptionProtocol->None,FromAddress->None, FromName->None,Password->Automatic,PortNumber->Automatic, ReplyTo->Automatic,Server->None,ServerAuthentication->Automatic, Signature->None,UserName:>$UserName
|>
*)


This variable will reflect changes made by the user through the Preferences dialog.

• interesting, it looks like this is just reading the file that rhermans detected via ResourceLocatorPrivategetPreferenceFile["SendMail", \ "MailSettings", PreferencesRead]. Interestingly there is also a corresponding file "MailSettingsNew". I think the combination of your answers gives a quite complete picture... – Albert Retey Sep 20 '17 at 21:14

Thanks to rhermans and WReach my question is not only answered but it also is clear what is going on:

In version 11.2 the variable ExternalServiceMailSettings$MailSettings will contain the settings as given in the preferences. The source of that information is the file "ApplicationData\SendMail\Preferences\MailSettingsNew.m", while older versions used "ApplicationData\SendMail\Preferences\MailSettings.m" for that purpose. Looking at the (readprotected) code for ExternalServiceMailSettings$MailSettings shows that it uses ExternalServiceMailSettingsLoadMailSettings to load those settings. That does use the functions from the package "ResourceLocator" to load that file using Get for the filename returned by ResourceLocatorPrivategetPreferenceFile["SendMail", "MailSettingsNew", PreferencesRead].

ExternalServiceMailSettingsLoadMailSettings` will also take care of converting an old settings file to a new one.