SendMail (sending emails)
function SendMail(
from: string, // sender (RFC-822 format)
to: string, // recipient(s) (RFC-822 format, semicolon-separated for multiple)
subj: string, // subject
body: string, // body of the email
attach: string // full path to a file to attach (optional, use '' for none)
): boolean;Sends an email using the mail settings of your Server!'s virtual site (the SMTP page of the Admin UI). This avoids exposing sensitive information in your scripts and is the preferred way to send emails from Syncplify Server! scripts.
The script does not change with the delivery method of the virtual site. The same call sends through an SMTP server, through Microsoft 365 or through Google Workspace, whichever the site is set to; see Email through Microsoft 365 and Google Workspace.
The function returns true when the message was accepted for delivery and false when it was not. The reason for a false is written to the log.
NOTE
The to parameter can include multiple recipients, separated by a semicolon (;).
NOTE
An empty from uses the sender address of the virtual site. With Microsoft 365 and Google Workspace the sender must be the mailbox the site sends from, or an address that mailbox may send as: Microsoft refuses any other, and Gmail replaces it with the mailbox's own address.
NOTE
When the file named in attach does not exist, the message is sent without it and a warning is written to the log. With Microsoft 365 a message can carry only a few megabytes of attachments; a larger one is not sent.
Example
SendMail(
'me@me.me',
'you@you.com;it@they.com',
'NEW BACKUP UPLOADED!',
'A new backup has been uploaded!',
''
);