Skip to main content

$mail

The $mail built-in service allows sending email messages from the bot script.

caution
To use the $email service, you will need a mail server implementing the SMTP protocol. You can try ready-to-use cloud solutions or run your own server.

Another option to send email messages is to use the Email action tag: it doesn’t require you to configure a mail server. However, all messages will have as their sender.

Methods

MethodDescription
configConfigure the SMTP server settings.
debugEnable or disable the $mail service debug mode.
sendSend an email message and pass the SMTP server settings.
sendMessageSend an email message via the pre-configured SMTP server.

SMTP server configuration

When your server is ready to use, you need to provide its settings in the script. This can be done in several ways:

injector:
smtp:
host: smtp.just-ai.com # SMTP server host
port: 2525 # SMTP server port
user: user@just-ai.com # SMTP server user
password: qwerty # SMTP server password
from: bot@just-ai.com # Email sender

# Optional properties
hiddenCopy: admin@just-ai.com # Email hidden copy recipient
# You can specify a list of recipients:
# hiddenCopy:
# - admin@just-ai.com
# - support@just-ai.com
debugMode: true # Whether debug mode is on or off
tip
The recommended way to provide the settings is to use the $mail methods instead of chatbot.yaml. This allows you to store them separately from the script as secrets and variables rather than in the source code. You will be able to modify the settings easily without changing the code, and sensitive data will be more secure.