3 Replies - 1955 Views - Last Post: 10 February 2014 - 05:12 PM Rate Topic: -----

#1 VB ASRAAF007  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 87
  • Joined: 11-April 12

Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must

Posted 09 February 2014 - 07:19 AM

Hello people,
i've been doing the password recovery in php...im encountering with the problem

Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first in C:\xampp\htdocs\yakatrouver_test\recover_password.php on line 54



here are my codes:

<?

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("yakatrouver_test") or die(mysql_error());


if ($_POST['submit']){
	
	$username = $_POST['username'];
	$email = $_POST['email'];
	
	if($username && $email){
		
		$passwordlength = 10;
		$charset = "abcdefghijklmnopqrstuvwxyz1234567890";
		
		for($x = 1; $x <= $passwordlength; $x++){
			$rand = rand() % strlen ($charset);
			$temp = substr ($charset, $rand, 1);
			$password .= $temp;			
			
		}
		
		$password_md5 = md5($password);
		
		
		$query_01 = mysql_query("SELECT * FROM 	`recover_password` WHERE username = '$username' AND email = '$email'") or die(mysql_error());

		$query_01 = mysql_num_rows($query_01);
		
		
		if($query_01 != 0){
			
			$query_03 = mysql_query("UPDATE `recover_password` SET password = '$password_md5' WHERE email ='$email'");
			
			ini_set('smtp_port', 25);	
			ini_set('SMTP', "smtp.live.com");
			
			
			$to = "$email";
			$subject = "Your new password ";
			$headers = "From: no-reply@localserver.com";
			$body = "
					Hello $username, \n
					you recently requested a new password at local web server generated by Asraaf. 
					Follow the link below to reset your password\n
					
					http://localhost/yakatrouver_test/reset_password.php?ramdom=$password&username = $username\n
					
					Your password is :\n
					$password
			
			";
			mail($to, $subject, $body, $headers);
			echo "Your password has been sent to $email";
			
		}else {
			die("No user found\n");	
		}
		
	}else{
		die("You must type both username and password\n");		
	}
	
	
}
else{
	echo "<table>
	
	<form action='recover_password.php' method='post'>
	
	<tr>
		<td>
			Username : <input type='text' name='username'>
			
		</td>	
			
	</tr>	
	
	<tr>
		<td>
			Email : <input type='text' name='email'><br /><br /><input type='submit' name='submit' value='Get new password'>
			
		</td>	
			
	
	</tr>
	
	</table>
	
	";
	
}



?>


This post has been edited by macosxnerd101: 09 February 2014 - 08:53 AM
Reason for edit:: Fixed code tags and moved to PHP


Is This A Good Question/Topic? 0
  • +

Replies To: Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3069
  • View blog
  • Posts: 10,749
  • Joined: 08-August 08

Re: Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must

Posted 09 February 2014 - 09:21 AM

Sorry, I stop reading here: mysql_connect. MySQL functions are deprecated and should not be used for new code.

I suggest you read up on prepared statements in PDO or MySQLi.
Was This Post Helpful? 1
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must

Posted 09 February 2014 - 10:05 AM

The live.com SMTP servers apparently require SSL/TLS connections (STARTTLS), which is not something the simple mail() functions handles very gracefully. (Not even sure if it handles it at all.)

I'd suggesting upgrading to a more extensive mailer library for anything beyond simple text mails sent via sendmail. Swift Mailer or PHPMailer would be my recommendations.
Was This Post Helpful? 2
  • +
  • -

#4 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,619
  • Joined: 15-May 08

Re: Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must

Posted 10 February 2014 - 05:12 PM

The response code 530 denotes that you are not logged in. Perhaps have a look at this for HTTP response codes. PHPMailer will help you utilise SMTP.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1