0

I want to send mail to windows server using php but i am failed to sent mail. Please send the actual code for send mail using Windows server 2008...

$name=trim($_POST['name']);
$email=trim($_POST['email']);
$message=trim($_POST['textarea']);

ini_set("SMTP","gmail-smtp-in.l.google.com");
ini_set("smtp_port",25);
ini_set("sendmail_path","/usr/local/bin/sendmail");
ini_set("sendmail_from","$email");


$subject="One Request from ".$name;

$new_msz="My name is:- ".$name ." My Email Id:- ".$email ." Message:- ".$message;

$email_id="akwwwamit@gmail.com";
if(mail($email_id,$subject,$new_msz,$email))
{
        $ms="Successfully sent";
        $msz=base64_encode($ms);
        header("Location:write-us.php?da=$msz");
}
else
{
        $ms="Something problem try again";
        $msz=base64_encode($ms);
        header("Location:write-us.php?da=$msz");

}

1 Answers1

0

Have you got any mail server (MTA) on this Windows machine? In a windows environment PHP uses SMTP insted of the Linux binary sendmail (or replacement). Just set the SMTP server (it can be Google's one) according to this page: http://php.net/manual/en/mail.configuration.php

You can add local configuration directives to .htaccess file, here are more information: http://php.net/manual/en/configuration.changes.php , just insert something like:

SMTP = gmail-smtp-in.l.google.com
cezar
  • 587
  • 3
  • 10