jwalant Posted December 19, 2010 Share Posted December 19, 2010 Hello i m newbie to PHP. I am trying to host the website on my laptop but due to some configuration i cant send the emails through php script. I am trying send mail through mail() but not able to sent mail. heres the code: $to = "[email protected]"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } Output: Message delivery failed.. I read the previous post here. but I am not able to figure out what to do about it. Can anyone tell me what setting i do in my php.ini? or any other that necessary settings require for this. i don't have SMTP server on my laptop so is there any method from which i can setup the SMTP server on laptop.? I use apache HTTP 2.2 and PHP 5.3.4 Rest of the website working correctly but only mail not working. TY..!! Quote Link to comment https://forums.phpfreaks.com/topic/222117-not-able-to-send-mail-smtp-server/ Share on other sites More sharing options...
jwalant Posted December 19, 2010 Author Share Posted December 19, 2010 I use OS windows vista. 32-bit Quote Link to comment https://forums.phpfreaks.com/topic/222117-not-able-to-send-mail-smtp-server/#findComment-1149184 Share on other sites More sharing options...
trq Posted December 19, 2010 Share Posted December 19, 2010 Without a mail server you will need to use a third party script like PHPMailer (google it) to send mail via your internet providers (or any other provider really) host. PHP's mail function does not provide that ability to use authentication which any well configured mail server will require. Quote Link to comment https://forums.phpfreaks.com/topic/222117-not-able-to-send-mail-smtp-server/#findComment-1149185 Share on other sites More sharing options...
jwalant Posted December 19, 2010 Author Share Posted December 19, 2010 Do i need mail server to run that simple program? i uninstall the apache and php after going through various posts and video tutorials and i installed wamp server to test that program its giving me this 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:\wamp\www\test.php on line 5 Message delivery failed... My php.ini settings for smtp mail: [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = [email protected] is there anything wrong with the php.ini? Quote Link to comment https://forums.phpfreaks.com/topic/222117-not-able-to-send-mail-smtp-server/#findComment-1149312 Share on other sites More sharing options...
PFMaBiSmAd Posted December 19, 2010 Share Posted December 19, 2010 Do i need mail server to run that simple program? ^^^ Yes. Quote Link to comment https://forums.phpfreaks.com/topic/222117-not-able-to-send-mail-smtp-server/#findComment-1149320 Share on other sites More sharing options...
jwalant Posted December 19, 2010 Author Share Posted December 19, 2010 Thanks.. i will try to setup a email server on my laptop. then let me check..!! if you know any way to setup mail server then plz tell me. TY again..!! Quote Link to comment https://forums.phpfreaks.com/topic/222117-not-able-to-send-mail-smtp-server/#findComment-1149330 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.