[英]Not able to send mail using mail function in php
任何人都可以幫助我解決我的問題。.我無法使用php中的mail()發送郵件。這是我的代碼:
if (isset($_POST["from"])) {
$from = $_POST["from"]; // sender
$subject = $_POST["subject"];
$message = $_POST["message"];
$message = wordwrap($message, 70);
mail("test@example.com",$subject,$message,"From: $from\n");
echo "Thank you for sending us feedback";
}
當我在localhost中運行此程序時,輸出顯示為“謝謝您向我們發送反饋”,但在test@example.com中未收到任何郵件。
檢查您的php.ini配置文件並添加郵件服務器配置:
SMTP = server ; mail server
smtp_port = 25 ; port
sendmail_from = your@email.com ;
要么
使用PHPMailer https://github.com/PHPMailer/PHPMailer通過gmail,yahoo或任何外部郵件服務器發送郵件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.