Hello all,
I was wondering if anyone knew how to output values from php into an html email. Currently I have a table with the html email code which works properly. However, the emails are a little vague because I don’t know how to display field values in the html email. I’m currently attempting to send a robust html email containing a generated password for password recovery. That works great but I can only get the email to display the text with the temp password. I want to liven up the plain email but not sure where to put the html. I tried events and php methods to store the html code but can’t figure out how to pass the variable $decrypt from the code below.
/**
* Check for an existing record
*/
// SQL statement parameters
$check_table = 'sdh_sec_users'; // Table name
$check_where = "login = '{login}' AND email = '{email}'"; // Where clause
// Check for record
$check_sql = 'SELECT *'
. ' FROM ' . $check_table
. ' WHERE ' . $check_where;
sc_select(dataset, $check_sql);
if (false == {dataset})
{
// Error while accessing database
}
elseif ({dataset}->EOF)
{
// No record found
sc_error_message('The user or email you have entered was not found in the system');
}
else
{
$decrypt = {pswd};
{pswd} = md5({pswd});
// Record found
// SQL statement parameters
$update_table = 'sdh_sec_users'; // Table name
$update_where = "login = '{login}'"; // Where clause
$update_fields = array( // Field list, add as many as needed
"pswd = '{pswd}'",
"reset = '{reset}'",
);
// Update record
$update_sql = 'UPDATE ' . $update_table
. ' SET ' . implode(', ', $update_fields)
. ' WHERE ' . $update_where;
sc_exec_sql($update_sql);
sc_commit_trans();
$mail_smtp_server = 'mail.123comply.com';
$mail_smtp_user = 'temp@123comply.com';
$mail_smtp_pass = '1mpac7c0mp1y';
$mail_from = 'temp@123comply.com';
$check_sql2 = "SELECT login, pswd"
. " FROM sdh_sec_users"
. " WHERE login = '" . {login} . "'";
sc_lookup(rs, $check_sql2);
if (isset({rs[0][0]})) // Row found
{
$mail_subject = "Your password has been reset";
$temppasswd = [$_POST($decrypt)];
$mail_message = email();
//$mail_message ="Your temporary password is: ". $decrypt;
//$mail_message ="Your temporary password is". {rs[0][1]};
}
$check_sql3 = "SELECT email"
. " FROM sdh_sec_users"
. " WHERE email = '{email}'";
sc_lookup(rs, $check_sql3);
if (isset({rs[0][0]})) // Row found
{
$mail_to = {rs[0][0]};
}
$mail_format = 'H';
// Send email
{
sc_mail_send($mail_smtp_server,
$mail_smtp_user,
$mail_smtp_pass,
$mail_from,
$mail_to,
$mail_subject,
$mail_message,
$mail_format);
}
}
sc_commit_trans();
sc_redir(password_confirmation.php, '','_parent');
I hope I’ve made my issue clear enough. Any help would greatly appreciated.