Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

PHP email function error

the mail() function

Moderators: macek, egami, gesf

PHP email function error

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

HI,

I am using the following email function to mail

Code: Select all
<?php
$to = "xxx@xxx.com";
$subject = "test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
if(mail($to,$subject,$message,$headers))
{ echo "Mail sent"; }
else
{ echo "Mail failed"; }

?>


Im getting the error :

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



But mt PHP.ini settings are:
SMTP 127.0.0.1
smtp_port 25

Anyone plz help...
prog
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Feb 23, 2012 4:03 am

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 =192.168.0.12
smtp_port = 25

; For Win32 only.
sendmail_from =validaccount@192.168.0.12
;============== 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:
validaccount@192.168.0.12

to your needs.

I'm using it and i would like to say it works like charm for me.*At least on my network.
TheProdigyGuy
New php-forum User
New php-forum User
 
Posts: 215
Joined: Wed Dec 07, 2011 5:25 pm


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron