pritam79 Posted July 5, 2009 Share Posted July 5, 2009 I have this script which allows users to send email. Here's the script for the mail function. <html><body><?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email { //send email $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $message = $_REQUEST['message']; mail( "someone@example.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; }else//if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; }?></body></html> But on submitting the form, I get this output- 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\PHP\email\simple-email.php on line 13Thank you for using our mail form Do I need to make any changes in my php.ini file? The “SMTP” and "smtp_port" setting in my php.iniFile are set to “localhost” and “25” respectively Link to comment Share on other sites More sharing options...
justsomeguy Posted July 5, 2009 Share Posted July 5, 2009 Do you have a mail server running on your computer? Link to comment Share on other sites More sharing options...
pritam79 Posted July 6, 2009 Author Share Posted July 6, 2009 how do i get to know whether i have a mail server running on my computer? i m using the wamp server. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 6, 2009 Share Posted July 6, 2009 Wamp doesn't include a mail server. You can open a telnet session in the command prompt and try to telnet to localhost on port 25, if it connects then you have a mail server running, if not then you don't. If you don't know whether or not you do, you probably don't have one. Link to comment Share on other sites More sharing options...
pritam79 Posted July 7, 2009 Author Share Posted July 7, 2009 Ok, so there is no other way of testing the mail function locally except as described by you. It can be done easily on a remote mail server I guess. Is a mail server different from a normal remote web server? If the mail() function is included in a website, will the mail facility provided for the users require a separate remote mail server apart from the usual web server hosting the remaining site? Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 7, 2009 Share Posted July 7, 2009 It depends how the server is set up, but most professionally hosted web servers also have mail servers installed. Link to comment Share on other sites More sharing options...
pritam79 Posted July 8, 2009 Author Share Posted July 8, 2009 Thanks... In the PHP tutorials here I found a description of how to make an ODBC connection with an Access database, retrieving records, retrieving fields and closing an ODBC connection. What has an ODBC connection got to do while using PHP+MySQL? If a site is built with PHP+MySQL is there any need of ODBC, since we are using just MySQL? thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted July 8, 2009 Share Posted July 8, 2009 You can set up an ODBC connection to connect to a MySQL data source, but it's usually not necessary when MySQL will just listen on a certain socket that you can connect to. The mysql_connect function connects to a MySQL server on a certain socket. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.