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"] = "activate.social@gmail.com";
        $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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.