ScoRpion
ScoRpion

Reputation: 11474

Not Able to Send Mail Using PHP?

I am trying to send a mail through core Php, I have created a file email.php and included PHPMailer_v5.1 in it.. here is my php code,

<?php if($_POST){
$email = $_REQUEST['email'] ;
$comments = $_REQUEST['comments'] ;
$phone = $_POST['telephone'] ;
$name = $_REQUEST['name'] ;

$mail = new PHPMailer();
$mail->Host = "localhost";               
$mail->From = "[email protected]";
$mail->FromName  =  "Showket";
$mail->AddAddress("[email protected]");


$mail->Subject = "Feedback form results";
$mail->Body="
    Name: $name
    Email: $email
    Telephone: $telephone
    Comments: $comments";

$mail->WordWrap = 50;

if(!$mail->Send())
{
   echo 'Message was not sent.';
   echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
   echo 'Thank you for your feedback.';
}
} 
?>

when i post this form it gives me the right message Thank you for your feedback. but i didnt recieve the message..do i need to configure anything else ?

Upvotes: 0

Views: 269

Answers (2)

Geert
Geert

Reputation: 116

Try setting Gmail as your SMTP

<?php if($_POST){ 
$email = $_REQUEST['email'] ; 
$comments = $_REQUEST['comments'] ; 
$phone = $_POST['telephone'] ; 
$name = $_REQUEST['name'] ; 

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "ssl://smtp.gmail.com:465"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "password"; // SMTP password

$mail->Host = "localhost";                
$mail->From = "[email protected]"; 
$mail->FromName  =  "Showket"; 
$mail->AddAddress("[email protected]"); 

$mail->Subject = "Feedback form results"; 
$mail->Body=" 
Name: $name 
Email: $email 
Telephone: $telephone 
Comments: $comments"; 

$mail->WordWrap = 50; 

if(!$mail->Send()) 
{ 
    echo 'Message was not sent.'; 
    echo 'Mailer error: ' . $mail->ErrorInfo; 
} 
else 
{ 
    echo 'Thank you for your feedback.'; 
} 
}  
?>

Upvotes: 2

Raul Marengo
Raul Marengo

Reputation: 2373

Run "sendmail -bp" to check if there is anything in the queue. Also, check the email folder for the user that your webserver is running under to see if you have had any undeliverable notifications.

Upvotes: 0

Related Questions