Visualizzazione dei risultati da 1 a 2 su 2

Discussione: invio mail

  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    19

    invio mail

    ciao...ho un problema, non riesco ad inviare le mail in automatico da php.
    praticamente sto facendo un forum e nel caso in cui l'utente perda la password gli viene spedita una nuova password (di default) per mail.
    Il codice è questo, non mi da errori e viene visualizzata il messaggio che la mail è stata spedita, ma in realtà non arriva nessuna mail, come posso fare?

    if ($lostinfo == "password"){
    //if the user has lost his password he should insert his username and the system will send him a new default pwd
    ?>
    <h1>Password lost</h1>

    <form name="adduser" method="post" action="lostpassword.php">


    Insert your username

    <input type="text" name="username" /></p>


    <input type="submit" name="Submit" value="Submit" align="center" /></p>
    </form>
    <?
    //define the receiver of the mail
    $user= $_POST['username'];
    $sql= "SELECT * FROM user WHERE username='".$user."'";
    $result = mysql_query($sql, $connection)
    or die("Couldn't perform query $sql </br>".mysql_error());
    $row = mysql_fetch_array($result);
    if($row == null){
    echo "error";
    }
    $to = $row['email'];
    //define the subject of the email
    $subject = 'Password';
    //define the message to be sent. Each line should be separated with \n
    $message = "This mail is automatically generated.\nThe new password for the SOUND OFF Forum is password, you should change this password once logged in into the system\r\n";
    //define the headers we want passed. Note that they are separated with \r\n
    $headers = "From: admin-sound off-forum\r\nDo not reply to this email";
    //send the email
    //$mail_sent = mail( $to, $subject, $message, $headers );
    $mail_sent = mail( $to, $subject, $message );
    //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
    //echo $mail_sent ? "Mail sent" : "Mail failed";

    //set the default password as the password of the user
    $cryptedpwd=md5('password');
    $sql="UPDATE user SET password='".$cryptedpwd."' WHERE username= '".$user."'";
    $result = mysql_query($sql, $connection)
    or die("Couldn't perform query $sql </br>".mysql_error());

    if ($mail_sent) {
    echo "

    Message successfully sent to".$row['email']."</p>";
    } else {
    echo "

    Message delivery failed...</p>";
    }


    grazie 1000!!!

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    19
    Codice PHP:
                    if ($lostinfo == "password"){                     //if the user has lost his password he should insert his username and the system will send him a new default pwd                     ?>                   <h1>Password lost</h1>                                      <form name="adduser" method="post" action="lostpassword.php">                       

    Insert your username 
                           <input type="text" name="username" /></p>                       

    <input type="submit" name="Submit" value="Submit" align="center" /></p>                    </form>                    <?                          //define the receiver of the mail                   $user= $_POST['username'];                   $sql= "SELECT * FROM user WHERE username='".$user."'";                   $result = mysql_query($sql, $connection)                                       or die("Couldn't perform query $sql </br>".mysql_error());                   $row = mysql_fetch_array($result);                   if($row == null){                       echo "error";                   }                   $to = $row['email'];                   //define the subject of the email                   $subject = 'Password';                   //define the message to be sent. Each line should be separated with \n                   $message = "This mail is automatically generated.\nThe new password for the SOUND OFF Forum is password, you should change this password once logged in into the system\r\n";                   //define the headers we want passed. Note that they are separated with \r\n                   $headers = "From: admin-sound off-forum\r\nDo not reply to this email";                   //send the email                   //$mail_sent = mail( $to, $subject, $message, $headers );                   $mail_sent = mail( $to, $subject, $message );                   //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"                    //echo $mail_sent ? "Mail sent" : "Mail failed";                                      //set the default password as the password of the user                   $cryptedpwd=md5('password');                   $sql="UPDATE user SET password='".$cryptedpwd."' WHERE username= '".$user."'";                   $result = mysql_query($sql, $connection)                                       or die("Couldn't perform query $sql </br>".mysql_error());                                      if ($mail_sent) {                       echo "

    Message successfully sent to".$row['email']."</p>";                   } else {                   echo "

    Message delivery failed...</p>";                   }

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.