php mailing not working. any help me?


i used the code to send mail is as follows:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>


when i am executing i am getting following error:
Warning: mail() [function.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 C:\Program Files\xampp\htdocs\samplemuthu\file.php on line 7

Recommended Answers

All 3 Replies

Hi,

  1. Search your computer for the 'php.ini' file....
  2. Once you have found it's location, open it using Notepad.exe
  3. Click Edit - Find and enter [mail function] now search for it within the document
  4. You should find this:

    [mail function]
    ; For Win32 only.
    SMTP = localhost
    smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = me@example.com

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    ;sendmail_path =sendmail -t -i

Hi,You can use sleep() function just after mail($to,$subject,$message,$headers);
like this

mail($to,$subject,$message,$headers);
sleep(5);

may be it will works.

php mailing not working. any help me?


i used the code to send mail is as follows:
<?php
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>


when i am executing i am getting following error:
Warning: mail() [function.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 C:\Program Files\xampp\htdocs\samplemuthu\file.php on line 7

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.