-2

i have tried to send email from localhost in WAMP server but it shows me this error:

mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

i have edited the php.ini file like:

    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    SMTP = localhost
    ; http://php.net/smtp-port
    smtp_port = 25

my php file code is :

$to = '$rowemail["email"]';
$subject  = 'Testing sendmail.exe';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: [memarez@gmail.com' . "\r\n" .
        'MIME-Version: 1.0' . "\r\n" .
        'Content-type: text/html; charset=utf-8';
if(mail($to, $subject, $message, $headers))
    echo "Email sent";
else
    echo "Email sending failed";
ArK
  • 20,698
  • 67
  • 109
  • 136
Memar
  • 1
  • 1
  • 5
  • 3
    have you got a mailserver on your local machine? IIS? Mercury? etc This might be of interest though http://stackoverflow.com/questions/5773288/configure-wamp-server-to-send-email – Professor Abronsius Aug 08 '16 at 11:30
  • i have installed the "test mail server tool", but it didn't help out, it shows me same old error. – Memar Aug 08 '16 at 11:39

1 Answers1

-1

check this http://www.developerfiles.com/how-to-send-emails-from-localhost-apachephp-server/

However, i would suggest you to use libraries like phpmailer to send emails via smtp .. https://github.com/PHPMailer/PHPMailer

Mittul Chauhan
  • 417
  • 1
  • 6
  • 18