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.just-ai.com", // Host
2525, // Port
"user@just-ai.com", // User
$secrets.get("smtpPassword"), // Password
"bot@just-ai.com", // Sender
"admin@just-ai.com" // Hidden copy recipient
// ["admin@just-ai.com", "support@just-ai.com"] // 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.