简体   繁体   中英

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

I have installed xampp on my computer for a school project, and I also have access to an apache server at school where I can upload my files and run them.

<?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.");
?>

I can't get it to send the mail from either xampp or the apache server

You have to setup an smtp server if you don't already have one to send the mail. Then you need to edit the php config files to point to that server

You need an smtp server to send an email. You could set up a sendgrid account and then use the sendgrid class to send out an email. the api docs are very good.

http://sendgrid.com/docs/

Other vendors are available, they normally give you about 200 email outs a day for free. If this is a school project, then you could get away with that quota.

If you need to send out a few more you might have to look into setting up an smpt server. Or pay.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM