我正在使用 XAMPP,我想從數(shù)據(jù)庫表中選擇一個隨機(jī)記錄并通過電子郵件發(fā)送。我正在使用測試郵件服務(wù)器工具,但收到下一個錯誤:警告:mail():第 24 行 C:\xampp\htdocs\dailyapp\sender2.php 中的錯誤消息返回路徑 糟糕!出了點(diǎn)問題,我們無法發(fā)送您的消息。這里可能發(fā)生什么?任何想法?PHP代碼:<?php$servername = "localhost";$username = "root";$password = "";$dbname = "dapp";// Create connection$conn = new mysqli($servername, $username, $password, $dbname);// Check connectionif ($conn->connect_error) { die("Connection failed: " . $conn->connect_error);}$recipient = "mdrr5545@gmail.com";$sql = "SELECT * FROM my_messages ORDER BY RAND() LIMIT 1";$result = $conn->query($sql);if ($result->num_rows > 0) { ($row = $result->fetch_assoc()); $subject = $row["subject"]; $message = $row["message"]; if (mail($recipient, $subject, $message)) { http_response_code(200); echo "All good"; } else { http_response_code(500); echo "Oops! Something went wrong and we couldn't send your message."; }} else { echo 0;};?>
嘗試使用 mail() 從數(shù)據(jù)庫表發(fā)送記錄
哆啦的時光機(jī)
2023-10-15 15:23:40