Jump to content

Mail Function


pritam79
 Share

Recommended Posts

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

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

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

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

Edited by pritam79
Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...