Forgotten password email problem (General)

by Laurence ⌂ @, Edinburgh, Scotland, Friday, August 07, 2009, 10:47 (5377 days ago)

Hello

When a user clicks forgotten password, MLF sends the email to them successfully, but when they click the link in the email they see this in the browser:

Mail server not available - please try again later!

Any ideas?

Forgotten password email problem

by Laurence ⌂ @, Saturday, August 08, 2009, 18:59 (5376 days ago) @ Laurence

Can anyone help? Without this working, MLF is rendered pretty useless to me. I can invoke PHP's mail() function successfully, which is what I thought MLF used, so I don't know what could be wrong.

Alex, can you help - Forgotten password email problem

by Greg @, Tuesday, October 13, 2009, 00:13 (5311 days ago) @ Laurence

Alex,

Can you answer this question, I'm having this problem too.

Thanks,
Greg

Forgotten password email problem

by Mark Watson ⌂ @, Colorado, Thursday, November 05, 2009, 23:44 (5287 days ago) @ Laurence
edited by Mark Watson, Friday, November 06, 2009, 00:09

Same problem here. : Mail server not available - please try again later!

Just on the forgotten password function. Everything else seems to work fine.

Please help.

:-D

Oh yeah.... Linux, php 5, etc. Hosted on Bluehost. The email comes, you click the link, get the error, try later and it says "Code invalid" the second time. Need this feature to work. Any ideas?

Forgotten password email problem

by Egon @, Friday, November 06, 2009, 10:24 (5286 days ago) @ Mark Watson

Same problem here. : Mail server not available - please try again later!

Vermutlich ist die Funktion "mail()" in PHP deaktiviert. Gleiches Problem hatte ich auch. Der Hoster weigerte sich die die Funktion einzuschalten (SPAM-Problem).

Ich verwende jetzt einen E-Mail versandt über Smtp. Dazu habe ich ein Script smtpmail.php gefunden und so angepasst, das die Parameterübergabe gleich ist wie in "mail()". In MLF habe ich alle Funktionsaufrufe "mail()" in "smtpmail()" geändert. Die Smtp-Daten werden fest im Script eingetragen. Funktioniert einwandfrei.

Ich verwende zwar MLF 1.x, das müsste aber in 2.x genau so funktionieren.

Egon

Forgotten password email problem

by Mark Watson ⌂ @, Colorado, Friday, November 06, 2009, 11:29 (5286 days ago) @ Egon

Egon, Die Mail-Funktion nicht deaktiviert ist in PHP. Es läuft gut für alles bis auf die Funktion, die Kennwörter zurücksetzen. Vielen Dank, Mark

Forgotten password email problem

by Auge, Berlin, Friday, November 06, 2009, 15:22 (5286 days ago) @ Mark Watson

Hello

Egon, Die Mail-Funktion nicht deaktiviert ist in PHP. Es läuft gut für alles bis auf die Funktion, die Kennwörter zurücksetzen. Vielen Dank, Mark

Ok, the email is sent. You can click the link inside the email but the loaded page says something like "wrong code".

Two (for me) possible reasons:

  • The link contains a wrong code (I don't know the construction of the code).
  • The comparision between the sended code (in the link) and the saved code (in the database) is corrupted.

Sorry, but I can't do more for you. I have no solution for it.

Tschö, Auge

Forgotten password email problem

by Mark Watson ⌂ @, Colorado, Monday, November 09, 2009, 01:27 (5284 days ago) @ Egon

Does anyone have a clue how to fix this?

Forgotten password email problem

by Laurence ⌂ @, Friday, November 06, 2009, 08:52 (5286 days ago) @ Laurence

As I said, MLF was rendered pretty useless by this, so I went with PunBB instead. It's a normally laid out forum I know, but it's extremely fast, stable and feature rich so unfortunately it beats MLF for my purposes hands-down. A shame really!

Forgotten password email problem

by Mark Watson ⌂ @, Colorado, Friday, November 13, 2009, 15:01 (5279 days ago) @ Laurence

I really can't believe the developers of an awesome forum would totally ignore a problem like this. It saddens me to think I might have to switch, as this forum is exactly what I need. It is simple, it has the layout my users like, and the NECESSARY features. (Except the forgotten password function does not work.) There MUST be a fix for this. I have tried and I can't figure it out. I am new to this script and I'm not used to this code yet. CAN'T ANYONE HELP?

Forgotten password email problem

by Auge ⌂, Berlin, Friday, November 13, 2009, 20:10 (5279 days ago) @ Mark Watson

Hello

I really can't believe the developers of an awesome forum would totally ignore a problem like this. It saddens me to think I might have to switch, as this forum is exactly what I need. It is simple, it has the layout my users like, and the NECESSARY features.

Please remind that this is a private project of one person. There is only one developer (without trailing s). Maybe he is unreachable at the moment, but certainly he has a real live. Apart from that are you right, this problem needs a solution.

Tschö, Auge

Forgotten password email problem

by Auge, Monday, November 16, 2009, 00:44 (5277 days ago) @ Mark Watson

Hello

CAN'T ANYONE HELP?

Yes, everyone (except Alex) can't help. (wrong negotiation?)

... but, that is not true.

I think I know the code wich cause the error. All facts are based on mlf 2.1.1.

The facts:

  • generate a random string, a SHA1-hash based on the random string and push these data into the database and via email to the user
  • get back a request from the link in the email, make a comparision of the hashed code from the database and the random string from the email (URL-parameter code), if the comparision is successfull send a second email with the now generated password (at this point the error occurs!)
  • log in with the data from the second email

There is a difference between the ways, the two emails are sended. First one is sended via the function my_mail (includes/functions.inc.php, line 2052) where the headers and the subject are processed before sending the email. The second email is sended direct via mail (includes/login.inc.php, line 254). Headers are processed in a different way, so the error will be included in the source code of the email.

Please backup the file forum/includes/login.inc.php and change the content as follows. the first shown line ($lang['new_pw_email_txt'] ...) is 242.

includes/login.inc.php (old):

      $lang['new_pw_email_txt'] = str_replace("[name]", $field['user_name'], $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = str_replace("[password]", $new_pw, $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = str_replace("[login_link]", $settings['forum_address'].basename($_SERVER['PHP_SELF'])."?mode=login&username=".urlencode($field['user_name'])."&userpw=".$new_pw, $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = $lang['new_pw_email_txt'];
 
      $header = "From: ".my_mb_encode_mimeheader($settings['forum_name'], CHARSET, "Q")." <".$settings['forum_email'].">". MAIL_HEADER_SEPARATOR;
      $header .= "Content-Type: text/plain; charset=" . CHARSET . MAIL_HEADER_SEPARATOR;
      $header .= "Content-transfer-encoding: 8bit". MAIL_HEADER_SEPARATOR;
 
      $new_pw_mailto = my_mb_encode_mimeheader($field['user_name'], CHARSET, "Q")." <".$field['user_email'].">";
      if($settings['mail_parameter']!='')
       {
        if (@mail($new_pw_mailto, my_mb_encode_mimeheader($lang['new_pw_email_sj'], CHARSET, "Q"), $lang['new_pw_email_txt'], $header,$settings['mail_parameter']))
         {
          header("location: index.php?mode=login&login_message=pw_sent");
          die("<a href=\"index.php?mode=login&login_message=pw_sent\">further...</a>");
         }
        else die($lang['mail_error']);
       }
      else
       {
        if (@mail($new_pw_mailto, my_mb_encode_mimeheader($lang['new_pw_email_sj'], CHARSET, "Q"), $lang['new_pw_email_txt'], $header))
         {
          header("location: index.php?mode=login&login_message=pw_sent");
          die("<a href=\"index.php?mode=login&login_message=pw_sent\">further...</a>");
         }
        else die($lang['mail_error']);
       }

includes/login.inc.php (new):

      $lang['new_pw_email_txt'] = str_replace("[name]", $field['user_name'], $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = str_replace("[password]", $new_pw, $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = str_replace("[login_link]", $settings['forum_address'].basename($_SERVER['PHP_SELF'])."?mode=login&username=".urlencode($field['user_name'])."&userpw=".$new_pw, $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = $lang['new_pw_email_txt'];
 
      $new_pw_mailto = my_mb_encode_mimeheader($field['user_name'], CHARSET, "Q")." <".$field['user_email'].">";
      if(my_mail($new_pw_mailto, $lang['new_pw_email_sj'], $lang['new_pw_email_txt']))
       {
        header("location: index.php?mode=login&login_message=pw_sent");
        die("<a href=\"index.php?mode=login&login_message=pw_sent\">further...</a>");
       }
      else die($lang['mail_error']);
     }

The check if($settings['mail_parameter']!=''), wich is including the whole mail sending code in the old version of the file, is present inside the function my_mail. So it is not needed at this location anymore.

Please try it and leave a message here.

Tschö, Auge

Forgotten password email problem

by Mark Watson @, Monday, November 23, 2009, 01:09 (5270 days ago) @ Auge

Parse error: syntax error, unexpected T_ELSE in /home3/********/public_html/********/includes/login.inc.php on line 262

Forgotten password email problem

by Auge, Monday, November 23, 2009, 03:31 (5270 days ago) @ Mark Watson

Hello

Parse error: syntax error, unexpected T_ELSE in /home3/********/public_html/********/includes/login.inc.php on line 262

Are you shure that you use the version 2.1.1? I've tested it again and again and it's doing the job.

Tschö, Auge

Forgotten password email problem

by Mark Watson @, Thursday, November 26, 2009, 19:11 (5266 days ago) @ Auge

yes.... but maybe I am misunderstanding your code modification instructions.

Forgotten password email problem

by Auge, Thursday, November 26, 2009, 20:47 (5266 days ago) @ Mark Watson

Hello

yes.... but maybe I am misunderstanding your code modification instructions.

No, I think, my posted code is misleading. the codebox with the old code shows as last few lines:

 
      else
       {
        if (@mail($new_pw_mailto, my_mb_encode_mimeheader($lang['new_pw_email_sj'], CHARSET, "Q"), $lang['new_pw_email_txt'], $header))
         {
          header("location: index.php?mode=login&login_message=pw_sent");
          die("<a href=\"index.php?mode=login&login_message=pw_sent\">further...</a>");
         }
        else die($lang['mail_error']);
       }


The last bracket is the end of the first else (here: line 1) wich is the counterpart of if($settings['mail_parameter']!='') (should be line 254 in the old code; please compare to the old posting).

The shown new code contains a closing bracket too:

 
      if(my_mail($new_pw_mailto, $lang['new_pw_email_sj'], $lang['new_pw_email_txt']))
       {
        header("location: index.php?mode=login&login_message=pw_sent");
        die("<a href=\"index.php?mode=login&login_message=pw_sent\">further...</a>");
       }
      else die($lang['mail_error']);
     }


But: this bracket is the counterpart of the opening if from line 229. This said it may be, that you have a supernumerous closing bracket.

To make clear, what happens I will show the whole block for the case option "activate" (at line 222). Please compare it with your code, comments with leading and trailing "##########" are mine.

  case "activate": ########## line 222 ##########

  if (isset($_GET['activate']) && trim($_GET['activate']) != "" && isset($_GET['code']) && trim($_GET['code']) != "")
   {
    $pwf_result = mysql_query("SELECT user_id, user_name, user_email, pwf_code FROM ".$db_settings['userdata_table']." WHERE user_id = '".intval($_GET["activate"])."'", $connid);
    if (!$pwf_result) raise_error('database_error',mysql_error());
    $field = mysql_fetch_array($pwf_result);
    mysql_free_result($pwf_result);
    if(trim($field['pwf_code'])!='' && $field['user_id'] == $_GET['activate'] && is_pw_correct($_GET['code'],$field['pwf_code']))
     {
      // generate new password:
      if($settings['min_pw_length']<8) $pwl = 8;
      else $pwl = $settings['min_pw_length'];
      $new_pw = random_string($pwl);
      $pw_hash = generate_pw_hash($new_pw);
      $update_result = mysql_query("UPDATE ".$db_settings['userdata_table']." SET last_login=last_login, registered=registered, user_pw='".mysql_real_escape_string($pw_hash)."', pwf_code='' WHERE user_id='".$field["user_id"]."' LIMIT 1", $connid);
 
      // send new password:
      $smarty->config_load($settings['language_file'],'emails');
      $lang = $smarty->get_config_vars();
 
########## next line: 242 (without this comment) ##########
      $lang['new_pw_email_txt'] = str_replace("[name]", $field['user_name'], $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = str_replace("[password]", $new_pw, $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = str_replace("[login_link]", $settings['forum_address'].basename($_SERVER['PHP_SELF'])."?mode=login&username=".urlencode($field['user_name'])."&userpw=".$new_pw, $lang['new_pw_email_txt']);
      $lang['new_pw_email_txt'] = $lang['new_pw_email_txt'];
 
      $new_pw_mailto = my_mb_encode_mimeheader($field['user_name'], CHARSET, "Q")." <".$field['user_email'].">";
      if(my_mail($new_pw_mailto, $lang['new_pw_email_sj'], $lang['new_pw_email_txt']))
       {
        header("location: index.php?mode=login&login_message=pw_sent");
        die("<a href=\"index.php?mode=login&login_message=pw_sent\">further...</a>");
       }
      else die($lang['mail_error']);
     }
    else
     {
      header("location: index.php?mode=login&login_message=code_invalid");
      die("<a href=\"index.php?mode=login&login_message=code_invalid\">further...</a>");
     }
   }
   else
    {
     header("location: index.php?mode=login&login_message=code_invalid");
     exit;
    }
  break;
 }
 
$smarty->assign('action',$action);

Tschö, Auge

PS (to Alex): I could not set a single link inside the posting because the spamtest routine rejects the posting with the link.

Forgotten password email problem

by Charley @, Monday, December 14, 2009, 09:07 (5248 days ago) @ Auge

Hi, Auge. I implemented your fix and it works! Thanks!

RSS Feed of thread