【发布时间】:2020-06-14 08:31:35
【问题描述】:
我收到一个错误
警告:mail():SMTP 服务器响应:530 5.7.0 必须先发出 STARTTLS 命令。 z10sm5799896oih.1 - 第 47 行 C:\wamp64\www\Change.php 中的 gsmtp
我用谷歌搜索了它,但找不到任何有帮助的东西。我不确定下一步该怎么做 请帮忙
这是代码
<?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.";
}
?>
【问题讨论】:
-
我不确定。我不是最好的 php。
-
我会用什么替换 mail($userExists["email"], "www.*****.com - Password Reset", $mailbody);和?
标签: php