Hello and thanks for reading my post. I am a complete beginner and appreciate any help or guidance.
I have been playing with a script to send out a new welcome mail when someone signs up. I can get a message out when someone changes their password, but not when someone signs up. It is adapted from a different script that I picked up off the web.
Is there something blatently wrong with this that would prevent the welcome message going out and am I missing it?😕
<?
class Mailer
{
function sendWelcome($user, $email, $pass){
$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
$subject = "Welcome to The Club";
$body = $user.",\n\n"
."Welcome! You've just registered at The Club "
."with the following information:\n\n"
."Username: ".$user."\n"
."Password: ".$pass."\n\n"
."If you ever forget your password, a new "
."password will be generated for you and sent to this "
."email address, if you would like to change your "
."email address you can do so by going to the "
."login page after signing in.\n\n"
."Have a great day";
return mail($email,$subject,$body,$from);
}
function sendNewPass($user, $email, $pass){
$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
$subject = "Your new password From the Club";
$body = $user.",\n\n"
."We've generated a new password for you "
."and you can use this new password with your "
."username to log in to The Club.\n\n"
."Username: ".$user."\n"
."New Password: ".$pass."\n\n"
."It is recommended that you change your password "
."after signing back in\n\n"
."The Club";
return mail($email,$subject,$body,$from);
}
};
/* Initialize mailer object */
$mailer = new Mailer;
?>
the other bit of the code is......
if($database->addNewUser($subuser, md5($subpass), $subemail)){
if(EMAIL_WELCOME){
$mailer->sendWelcome($subuser,$subpass,$subemail);
}
return 0; //New user added succesfully
}else{
return 2; //Registration attempt failed
}
}
}
Thanks for your help 🙂