Skip to main content

$mail.config

This method configures the settings of the SMTP server that will be used for sending email messages via the $mail.sendMessage method.

caution

Depending on how you call the method, it can set the server configuration:

  • for ECMAScript 5 and ECMAScript 6 at the same time;
  • for one of these runtimes only.

Syntax

The method accepts six arguments:

ArgumentTypeDescription
smtpHostStringSMTP server host.
smtpPortNumberSMTP server port.
userStringSMTP server user.
passwordStringSMTP server password.
fromStringEmail sender.
hiddenCopyString or string arrayEmail hidden copy recipient or list of recipients. This argument is optional.
$mail.config(
"smtp.tovie.ai", // Host
2525, // Port
"user@tovie.ai", // User
$secrets.get("smtpPassword"), // Password
"bot@tovie.ai", // Sender
"admin@tovie.ai" // Hidden copy recipient
// ["admin@tovie.ai", "support@tovie.ai"] // List of hidden copy recipients
);
tip
The settings will be used for all subsequent calls to the $mail.sendMessage method, until overridden by another $mail.config call.

How method works in ES5 and ES6

  • If you call $mail.config in the init tag, it sets the same configuration for all runtimes: ECMAScript 5 and ECMAScript 6.
  • If you call $mail.config in the script tag, it sets the configuration only for ECMAScript 5. If you call it in scriptEs6, it sets the configuration only for ECMAScript 6.

The $mail.sendMessage method uses the SMTP server configuration from the runtime where it is called.