Brand new to php, but having a ball with it. I needed a login system for my site and found one that seemed pretty straight forward (Jpmaster77). I thought it would be easier to use existing code and build off that as I got better. So far so good.

My problem is I can't get email to send. So I built a small email app separate from his code and it worked fine, proving that my ISP/Sever does send email.

The code looks fine in the "login system"

function sendNewPass($user, $email, $pass){
$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
$subject = "Cyberwerkstatt's Site - Your new password";
$body = $user.",\n\n"
."We've generated a new password for you at your "
."request, you can use this new password with your "
."username to log in to Cyberwerkstatt's Site.\n\n"
."Username: ".$user."\n"
."New Password: ".$pass."\n\n"
."It is recommended that you change your password "
."to something that is easier to remember, which "
."can be done by going to the My Account page "
."after signing in.\n\n"
."-Cyberwerkstatt's Site";

  return mail($email,$subject,$body,$from);

The entire "Login system" is built with classes and everything "includes" the "session" class. I don't see anything out of order there.

So any help would be appreciated and I guess I am getting my first taste of reverse engineering!

Thanks in advance

356cabbie

    Dunno if I'm grokking your situation very well, but have you tried something similar to:

    $success=mail($email,$subject,$body,$from);
    if ($success)  {
       echo "It works!"; 
    } else {
       echo "Mail crapped out again.";
    }

    I've never used "return" to call [man]mail/man, so I dunno what's up with that (but I've basically got to a point with PHP where I feel like I've learned enough to do what I want to do).

    At any rate, assuming we get the "else" path above, I'd start by reading mail logs on the server. Of course, since you said "my ISP/Sever does send mail", you don't have access to those?

    Does this "framework" (for lack of a better term) redefine the [man]mail/man function? Are EMAIL_FROM_NAME and EMAIL_FROM_ADDR valid at the time the code above is executed? I assume they have to be defined somewhere else, in which case testing a call to

    defined('EMAIL_FROM_NAME');

    might shed light on the subject....

    Finally, are you sure it's not being sent? Maybe it's rejected with some error (in which case adding an "Errors-to" header might help), or caught in a spam filter somewhere....

      Write a Reply...