0

Hi friends I am new to php.. I created one mail function for my live website. (below is my code) But when i am pressing submit button one error is coming.

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in E:\HostingSpaces\aba0d8c0\smartraysolutions.com\wwwroot\contact.php on line 25

I really don't know how to resolve this issuee.... I am totally blank I asked my hosting provider about this, so he send me this msg

Kindly send mails through SMTP authentication. Kindly check below details. Nobody can send mail without authentication or local host, Due to security we have set on authentication bases so you will have to use authentication. Please Use this in your script.

Smtp server name---->mail.yourdomainname.com Smtp port ------->25 username-------------->?????@yourdomainname.com password-------------->your Email id password

   <?php

        if(isset($_POST['submit'])){

        $name=$_POST['name'];
        $email=$_POST['email'];
        $phone=$_POST['phone'];
        $msg=$_POST['msg'];

        $headers =  'MIME-Version: 1.0' . "\r\n"; 
        $headers .= 'From: SmartRay <www.smartraysolutions.com>' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

        if(empty("$name") || empty("$email") || empty("$phone") || empty("$msg")){
            $error_msg = "* Please fill all the fields";
        } else {
            // the message
            $full_msg = "Name: " . $name . "\n" . "Email Id: " . $email . "\n" . "Phone No.: " . $phone . "\n" . "Message: " . $msg;

            // use wordwrap() if lines are longer than 70 characters
            $msg = wordwrap($msg,70);

            // send email
            //mail("support@smartraysolutions.com","My subject",$full_msg);
            mail("akkii922@gmail.com","My subject",$full_msg,$headers);

            echo "<script type='text/javascript'>alert('Thank you for writing us. Our Team will contact you soon!')</script>";

            $sent_msg = "";
            $name="";
            $email="";
            $phone="";
            $msg="";
        }

    }

    ?> 

plz give me the detailed answer because i am newbee... THANKS

Akshay Kumar
  • 549
  • 7
  • 19
  • to use SMTP authentication you can't use php's buit in `mail()`, look at phpmailer or swiftmailer –  Oct 08 '15 at 19:54
  • Can you give me some example mail code with smtp... if possible.. or modify my code.... I am in trouble... And i really dont know php welll.... But i need to apply mail function in my web page.... Thanks – Akshay Kumar Oct 08 '15 at 20:24

0 Answers0