11
$\begingroup$

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?

$\endgroup$
9
$\begingroup$

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]
$\endgroup$
8
$\begingroup$

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

ExternalService`MailSettings`$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.

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

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 ExternalService`MailSettings`$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 ExternalService`MailSettings`$MailSettings shows that it uses ExternalService`MailSettings`LoadMailSettings to load those settings. That does use the functions from the package "ResourceLocator`" to load that file using Get for the filename returned by ResourceLocator`Private`getPreferenceFile["SendMail", "MailSettingsNew", PreferencesRead].

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.