Jump to content

email not sending


Glenskie

Recommended Posts

this is a forgot password page and this email script will not send

<?php
$emailcut = substr($email, 0, 4); // Takes first four characters from the user email address
			$randNum = rand(); 
                $tempPass = "$emailcut$randNum"; 
			$hashTempPass = md5($tempPass);

                @mysql_query("UPDATE myMembers SET password='$hashTempPass' where email='$email'") or die("cannot set your new password");

                include('Mail.php');
        include('Mail/mime.php');

        // Constructing the email
        $sender = "Social network";                                            // Your email address
        $recipient = "$email";                               // The Recipients name and email address
        $subject = "Reset Your Password";                                                // Subject for the email
        $text = 'This is a text message.';                                      // Text version of the email
        $html = "<html><body><div align=center><br>----------------------------- New Login Password --------------------------------<br><br><br>
                Your New Password for our site is: <font color=\"#006600\"><u>$tempPass</u></font><br><br />
			</div></body></html>";      // HTML version of the email
        $crlf = "\n";
        $headers = array(
                        'From'          => $sender,
                        'Return-Path'   => $sender,
                        'Subject'       => $subject
                        );

        // Creating the Mime message
        $mime = new Mail_mime($crlf);

        // Setting the body of the email
        $mime->setTXTBody($text);
        $mime->setHTMLBody($html);

        // Add an attachment
        

        // Set body and headers ready for base mail class
        $body = $mime->get();
        $headers = $mime->headers($headers);

        // SMTP authentication params
        $smtp_params["host"]     = "smtp.gmail.com";
        $smtp_params["port"]     = "587";
        $smtp_params["auth"]     = true;
        $smtp_params["username"] = "[email protected]";
        $smtp_params["password"] = "pass";

        // Sending the email using smtp
        $mail =& Mail::factory("smtp", $smtp_params);
        $result = $mail->send($recipient, $headers, $body);

if (PEAR::isError($mail)) {
   $outputForUser = '<font color="#FF0000">Password Not Sent.<br /><br />
                                                                  Please Contact Us...</font>';
  } else {
  $outputForUser = "<font color=\"#006600\"><strong>Your New Login password has been emailed to you.</strong></font>";
  }



     }

} else  {

   $outputForUser = 'Enter your email address into the field below.';

}



?>


Link to comment
https://forums.phpfreaks.com/topic/248142-email-not-sending/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.