Hi,
I am using the function below to send my mail. I am testing it but i cant quite see why it isn’t working?
Any ideas or improvements.
[code=php]
// Calling the function
$user_id = 6
SendEmail(“ActivationAdmin_Confirm”, $user_id);
// The function in the config file
// Send Email //
function SendEmail($message, $user_id) {
// Connection //
if (!($sql_id = @mysql_connect(MySQL_SERVER, MySQL_USERNAME, MySQL_PASSWORD))) {
if (SQL_SHOW_ERRORS == “true”) SamePageErrorMsg(“mysql_connect”, $sql_id);
}
// Activate database //
if (!@mysql_select_db(MySQL_DATABASE, $sql_id)) {
if (SQL_SHOW_ERRORS == “true”) SamePageErrorMsg(“mysql_select_db”, $sql_id);
}
// Query the database //
$sql_query = “SELECT * FROM “.DATABASE_PREFIX.”users WHERE Username = ‘$user_id’ LIMIT 1”;
$sql_query = (@mysql_query($sql_query, $sql_id));
if (!$sql_query) {
if (SQL_SHOW_ERRORS == “true”) SamePageErrorMsg(“mysql_insert”, $sql_id);
}
while ($row = mysql_fetch_array($sql_query)) {
extract($row);
switch ($message) {
case “Activation_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “Your activation number is “.$row[‘ActivationNum’].”.n”;
$msg .= “n”;
$msg .= “Please click on the link below to activate your accountn”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”?actnum=”.$row[‘ActivationNum’].”n”;
$msg .= “n”;
$msg .= “If you experieance any problems please copy and paste this link into your browser and type the activation number into the appropriate place.n”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Activation Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Activation <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;
case “ActivationAdmin_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “Your activation number is “.$row[‘ActivationNum’].”.n”;
$msg .= “n”;
$msg .= “Please click on the link below to activate your accountn”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”?actnum=”.$row[‘ActivationNum’].”n”;
$msg .= “n”;
$msg .= “After you have activated your account you must wait for a member of “.SITE_NAME.” to confirm your registration. We aim to activate your account within “.EMAIL_RESPONDT.”.n”;
$msg .= “n”;
$msg .= “If you experieance any problems please copy and paste this link into your browser and type the activation number into the appropriate place.n”;
$msg .= “”.EMAIL_ACTIVATIONLINK.”n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Activation Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Activation <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;
case “Admin_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “n”;
$msg .= “Your must wait for a member of “.SITE_NAME.” to confirm your registration. We aim to activate your account within “.EMAIL_RESPONDT.”.n”;
$msg .= “n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Admin Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Admin <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;
case “Registration_Confirm”:
$msg = “Hi “.$row[‘Salutation’].” “.$row[‘FirstName’].” “.$row[‘LastName’].”nn”;
$msg .= “** This is an automated email**n”;
$msg .= “n”;
$msg .= “Thank you for registering to “.SITE_NAME.”.n”;
$msg .= “n”;
$msg .= “Your account is fully registered. Please find your details below: -n”;
$msg .= “Your Username is: – “.$row[‘Username’].”.n”;
$msg .= “n”;
$msg .= “Your password is not sent for security reasons, but if you do forget your password you can request a new one here.n”;
$msg .= “n”;
$msg .= “”.EMAIL_LOSTPASSWORD.”n”;
$msg .= “n”.EMAIL_COPYRIGHT.””; // Copyright Link
$recipient = “”.$row[‘Email’].””; // Recipient Address
$subject = “”.SITE_NAME.” Admin Confirm”; // Email Subject
$mailheaders = “From: “.SITE_NAME.” Admin <[email protected]> n”;
//$mailheaders = “Reply-To: $_POST[email]”;
break;
}
mail($recipient, $subject, $msg, $mailheaders);
}
}
Thanks
Adam