PHP email function error

the mail() function

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Thu Feb 23, 2012 4:03 am

PHP email function error

Postby prog » Thu Feb 23, 2012 4:09 am


I am using the following email function to mail

Code: Select all

$to = "";
$subject = "test mail";
$message = "Hello! This is a simple email message.";
$from = "";
$headers = "From:" . $from;
{ echo "Mail sent"; }
{ echo "Mail failed"; }


Im getting the error :

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

But mt PHP.ini settings are:
smtp_port 25

Anyone plz help...

New php-forum User
New php-forum User
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm

Re: PHP email function error

Postby TheProdigyGuy » Fri Feb 24, 2012 3:44 pm

Hello prog.
You need setup mail server on you machine to send mails.
Install Hmail server (it's free and great software) then configure your php.ini

;=========== snippet from php.ini
[mail function]
; For Win32 only.
smtp_port = 25

; For Win32 only.
sendmail_from =validaccount@
;============== END OF SNIPPET==============

note: You have create simple rule on your mail server to send mails without authentication(for localhost only)
Plus you have to change:

to your needs.

I'm using it and i would like to say it works like charm for me.*At least on my network.

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest