簡體   English   中英

我無法通過xampp或遠程服務器使用php郵件功能發送電子郵件

[英]I can't get xampp or a remote server to send an email with my php mail function

我已經在學校項目的計算機上安裝了xampp,並且還可以訪問學校的apache服務器,在其中可以上傳文件並運行它們。

<?php
$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$rating=$_POST['Rating'];
$subject= "review from website";
$name=$_POST['lname'].", ".$_POST['name'];
$from = $_POST['email'];
$to ="bricebathel@hotmail.com; bbathel@pembaserv.com;".$from.";";
$messageTo="BBComputers";
$headers = "From:" . $from;
$message = htmlspecialchars($_POST['comment']);
$about = $_POST['product'];
$date=date("j-n-y \a\\t g:ia\n");
mail($to,$subject,$message,$headers);
echo "<p id='contactUsData'>Message Sent to: ".$messageTo."<br>Date: ".$date."<br>                       From: ".$name."<br> About: ".$about."<br> Rating: ".$rating."<br> Message:".$message."<//p>";


$file_message="From: ".$name."\nEmail: ".$from."\nAbout: ".$subject."\nRating:   ".$rating."\nMessage: ".$message;
$file= fopen("data/feedback.txt","a")
    or die("Error: Could not open the log file.");
fwrite($file,"\n----------------------------\n")
    or die("Error: Could not open the log file.");
fwrite($file,"Received: ".$date."\n")
    or die("Error: Could not open the log file.");
fwrite($file,$file_message)
    or die("Error: Could not open the log file.");
?>

我無法從xampp或apache服務器發送郵件

如果還沒有發送郵件的服務器,則必須設置一個smtp服務器。 然后,您需要編輯php配置文件以指向該服務器

您需要一個smtp服務器才能發送電子郵件。 您可以設置一個sendgrid帳戶,然后使用sendgrid類發送電子郵件。 api文檔非常好。

http://sendgrid.com/docs/

還有其他供應商,它們通常每天免費為您提供200封電子郵件。 如果這是一個學校項目,那么您可以免除該配額。

如果您需要發送更多信息,則可能必須考慮設置smpt服務器。 或付錢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM