rahul_jjj Posted December 23, 2008 Share Posted December 23, 2008 I am new to Php and I am using php5 with apache. I wanted to have a code which can send an email automatically from the system.. I have the below code with me... $to = "abcde@in.com"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = 'From: .'."test".' <xxxxx@in.com>'; $headers = "From: $from"; mail($to,$subject,$message,$headers); Can anyone advise me on this as I am not able to send eny email with this. Quote Link to comment https://forums.phpfreaks.com/topic/138164-how-to-send-an-email-from-php5/ Share on other sites More sharing options...
Yesideez Posted December 23, 2008 Share Posted December 23, 2008 $to='some@somewhere.net'; $subject='This is a subject string'; $message='This is the body'."\n\n".'On multiple lines'; $headers='From: Your Name <your@email.net>'."\r\n"; $headers.='Reply-To: Your Name <your@email.net>'."\r\n"; $headers.='Reply-Path: Your Name <your@email.net>'."\r\n"; if (mail($to,$subject,$message,$headers)) { echo 'Sent.'; } else { echgo 'Failed.'; } Quote Link to comment https://forums.phpfreaks.com/topic/138164-how-to-send-an-email-from-php5/#findComment-722202 Share on other sites More sharing options...
rahul_jjj Posted December 23, 2008 Author Share Posted December 23, 2008 I tried the same and it says "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 " What all do I have to configure in php.ini file ? Quote Link to comment https://forums.phpfreaks.com/topic/138164-how-to-send-an-email-from-php5/#findComment-722219 Share on other sites More sharing options...
Yesideez Posted December 23, 2008 Share Posted December 23, 2008 Sounds like the settings aren't quite there - hopefully someone will be able to help you with this one as I've never had this error. Quote Link to comment https://forums.phpfreaks.com/topic/138164-how-to-send-an-email-from-php5/#findComment-722221 Share on other sites More sharing options...
PravinS Posted December 23, 2008 Share Posted December 23, 2008 Upload on any php supporting server and check. SMTP is not configured on you local machine so u r getting that error Quote Link to comment https://forums.phpfreaks.com/topic/138164-how-to-send-an-email-from-php5/#findComment-722223 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.