OR …
Step 1. Create the PHP method (aka function) to send the mail
Step 2. Call that function from the appropriate event (this is called from OnAfterInsert)
PHP Method:
$sql = “SELECT
email
FROM
sec_users
WHERE
group_id = 1” ; //Administator only
sc_lookup(rs,$sql);
$emails_admin = array();
if({rs} !== FALSE && count({rs}) != 0)
{
foreach({rs} as $value)
$emails_admin[] = $value[0];
}
//2014-0826:bh Changed implode to use semi-colon rather than comma
//To correct error RFC 2822 compliance
$emails_admin = implode(’; ', $emails_admin);
// 2015-0814:bh Modified to get smtp settings from table (was hard coded)
// Get SMTP Settings
sc_lookup(dataset, “select smtp_host, smtp_user, smtp_pass, smtp_email, smtp_port from smtp_settings where active = ‘Y’”);
if ({dataset} === false)
{
echo “Access error. Message=”. {dataset_erro} ;
}
elseif (empty({dataset}))
{
echo “Select command didn’t return data”;
}
else
{
// Email parameters
$mail_smtp_server = {dataset[0][0]}; // SMTP server name or IP address
$mail_smtp_user = {dataset[0][1]}; // SMTP user name
$mail_smtp_pass = {dataset[0][2]}; // SMTP password
$mail_from = {dataset[0][3]}; // From email
$mail_port = {dataset[0][4]}; // SMTP port
$mail_to = $emails_admin ; // Mail to administrators
$mail_message = sprintf({lang_new_user_sign_in}, {name}, {email}, {email});
$mail_subject = {lang_subject_mail_new_user};
$mail_format = ‘H’; // Message format: (T)ext or (H)tml
// Send email
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_format,
‘’,’’, $mail_port, ‘’);
}