perkeyone
something clever
- Reaction score
- 71
I made an address book in php and would like users to be able to send emails to their contacts from it. Here is one of my failed attempts.
the script outputs "Message successfully sent!" but the emails never arrive. not even in the spam folder. ive done a lot of google'ing on the subject but have only confused myself even more. the solutions that i found ranged from changing the order of the headers to not using carriage return and newline. i also noticed people mentioning smtp and pear, neither of which i know how to use, nor do i know if they are required to send an email. anyways, im gonna keep searching.
Code:
<?php
$to = "_@_.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "_@_.com";
$headers = "";
$end="\n";
$headers .= "MIME-Version: 1.0".$end;
$headers .= "Content-type: text/plain; charset=iso-8859-2".$end;
$headers .= "Content-Transfer-Encoding: 8bit".$end;
$headers .= "X-Priority: 1".$end;
$headers .= "X-MSMail-Priority: High".$end;
$headers .= "From: ".$from.$end;
$headers .= "Reply-To: ".$from.$end;
$headers .= "X-Mailer: PHP/".phpversion().$end;
$headers .= "To: ".$to.$end;
$headers .= "Return-Path: ".$from.$end;
$headers .= "X-Sender: ".$from.$end;
if(mail($to,$subject,$message,$headers)){
echo("<p>Message successfully sent!</p>");}
else{
echo("<p>Message delivery failed...</p>");}
echo "end of script";
?>
the script outputs "Message successfully sent!" but the emails never arrive. not even in the spam folder. ive done a lot of google'ing on the subject but have only confused myself even more. the solutions that i found ranged from changing the order of the headers to not using carriage return and newline. i also noticed people mentioning smtp and pear, neither of which i know how to use, nor do i know if they are required to send an email. anyways, im gonna keep searching.