![](/img/trans.png)
[英]php mail function error -> Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first
[英]PHP SMTP ERROR: SMTP server response: 530 5.7.0
我收到一個錯誤
警告:mail():SMTP 服務器響應:530 5.7.0 必須首先發出 STARTTLS 命令。 z10sm5799896oih.1 - C:\\wamp64\\www\\Change.php 中的 gsmtp 第 47 行
我用谷歌搜索過它,找不到任何有幫助的東西。 我不知道接下來要做什么,請幫忙
這是代碼
<?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. 嘗試telnet使用telnet 命令可以實際測試端口是否打開。
嘗試這個:
//Type the following command to see if Port 25 is blocked on your network.
telnet pepipost.com 25
如果端口 25 未被阻止,您將收到成功的 220 響應(文本可能會有所不同)。
Trying 202.162.247.93...
Connected to pepipost.com.
Escape character is '^]'.
220 pepipost.com ESMTP Postfix
如果端口 25 被阻止,您將收到連接錯誤或根本沒有響應。
Trying 202.162.247.93...
telnet: connect to address 202.162.247.93: Connection refused
telnet: Unable to connect to remote host
2.使用outPorts
outPorts是 GitHub 上一個非常好的開源軟件,它會掃描您所有的端口並給出結果。 安裝 outPorts 后,您可以在終端中鍵入以下命令來檢查端口 25 的連接性:outPorts 25
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.