简体   繁体   中英

PHP SMTP ERROR: SMTP server response: 530 5.7.0

I am getting a error

Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. z10sm5799896oih.1 - gsmtp in C:\\wamp64\\www\\Change.php on line 47

I have googled it and cant find anything that has helped. I am not sure what to do next please help

This is the code

<?php
// Connect to MySQL
$username = "*****"; 
$password = "*****"; 
$host = "*********"; 
$dbname = "*****"; 
try {
$conn = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
}
catch(PDOException $ex) 
{ 
    $msg = "Failed to connect to the database"; 
} 

// Was the form submitted?
if (isset($_POST["ForgotPassword"])) {

// Harvest submitted e-mail address
if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
    $email = $_POST["email"];

}else{
    echo "email is not valid";
    exit;
}

// Check to see if a user exists with this e-mail
$query = $conn->prepare('SELECT email FROM user WHERE email = :email');
$query->bindParam(':email', $email);
$query->execute();
$userExists = $query->fetch(PDO::FETCH_ASSOC);
$conn = null;

if ($userExists["email"])
{
    // Create a unique salt. This will never leave PHP unencrypted.
    $salt = "498#2D83B631%3800EBD!801600D*7E3CC13";

    // Create the unique user password reset key
    $password = hash('sha512', $salt.$userExists["email"]);

    // Create a url which we will direct them to reset their password
    $pwrurl = "www.yoursitehere.com/reset_password.php?q=".$password;

    // Mail them their key
    $mailbody = "Dear user,\n\nIf this e-mail does not apply to you please ignore it. It appears that 
 you have requested a password reset at our website www.*****.com\n\nTo reset your password, please 
click the link below. If you cannot click it, please paste it into your web browser's address 
bar.\n\n" . $pwrurl . "\n\nThanks,\nThe Administration";



 **This is where the error is**
    mail($userExists["email"], "www.*****.com - Password Reset", $mailbody);





    echo "Your password recovery key has been sent to your e-mail address.";

}
else
    echo "No user with that e-mail address exists.";
}
?>

1. Trying doing telnet Using telnet command you can actually test whether the port is opened or not.

try this:

//Type the following command to see if Port 25 is blocked on your network. 
telnet pepipost.com 25

If Port 25 is not blocked, you will get a successful 220 response (text may vary).

Trying 202.162.247.93... 
Connected to pepipost.com. 
Escape character is '^]'. 
220 pepipost.com ESMTP Postfix

If Port 25 is blocked, you will get a connection error or no response at all.

Trying 202.162.247.93...
telnet: connect to address 202.162.247.93: Connection refused
telnet: Unable to connect to remote host

2. Use outPorts
outPorts is a very good open-source on GitHub to which scans all your ports and gives the result. Once outPorts is installed, you can type the following command in the terminal to check port 25 connectivity: outPorts 25

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM