Is there a way to define the smtp parameters in a database record, rather than specifying them each time I add a new script to send email via smtp?
Yes, place your smtp parameters into field, then in the smtp script step then specify the correlating field.
Depends on how paranoid you want to be, if you want to access different email accounts, and how much work you want to be. If you're already storing email user/pass in a script, you're probably not that paranoid.
The simplest would be to use a Custom Function like:
smtpConfig ( setting ; account )
/*smtp.Config takes a parameter named setting of "server" "port" "user.name" or "password" and then returns the smtp entry for that setting based on the account specified in the parameter "account" */
Let ( [
server = "smtp.example.com" ;
port = "465" ;
user.name = Case (
account = "requests" ; "firstname.lastname@example.org" ;
account = "bob" ; "email@example.com " ;
account = "david" ; "firstname.lastname@example.org" ) ;
password = Case (
account = "requests" ; "abababa" ;
account = "bob"; "thebuilder";
account = "david" ; "password" ) ;
result = Case (
setting = "server" ; server ;
setting = "port" ; port ;
setting = "user.name" ; user.name ;
setting = "password" ; password )
In a script, I would set a variable like:
Set Variable [ $account ; "bob" ]
and then in SMTP settings, pass that like
user name = smtpConfig ( "user.name" ; $account )
You could also build a table to hold these values in fields. If security is a concern, you can use record level access privileges to pull the values from those fields by a script or even use an encrypted field.
Retrieving data ...