View Full Version : Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini

07-14-2007, 05:05 PM
i am using IBSERVER and trying to mail a form to my email address my code is given below


<form method="POST" action="mail.php">
Name: <input type="TEXT" name="subject">
Email: <input type="TEXT" name="email">
<input type="SUBMIT" name="Submit" value="ok">


$email = $HTTP_POST_VARS[email];
$mailsubj="Form submission";
reset ($HTTP_POST_VARS);
$mailbody="Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
if (!eregi("\n",$HTTP_POST_VARS[email])) {
mail($mailto, $mailsubj, $mailbody, $mailhead);
echo("Error, no comments were submitted!");

07-14-2007, 05:16 PM
You need an SMTP (http://en.wikipedia.org/wiki/SMTP) server, usually provided by your ISP.

07-16-2007, 02:53 PM
how can i get that i am running it on the local host using IB SERVER can you help me further please

07-16-2007, 03:25 PM
To be able to send email to anyone but yourself, you need a public mail server. Setting up your own public mail server has a lot of requirements (registered domain name, static IP address or a dynamic IP address and a dynamic DNS service, a name server, DNS records...) along with actually installing and configuring the mail server. You can skip some of these requirements and set up a local private mail server that only you can send to and only you can check mail on, but this still requires you to install and configure the mail server. There are some opensource mail servers (perhaps someone here can provide some links as I don't remember any of them off of the top of my head.)

If you are just wanting to send email to test your PHP script, you should use your ISP's mail server or if you have a web hosting account, use the mail server they provide. Most ISP's and web hosts will require you to use SMTP authentication to use their mail server and the PHP mail(...) function does not support authentication. In this case you would need to use something like the phpmailer class - http://phpmailer.sourceforge.net/

As far as the PHP SMTP setting, you need to set this to either the IP address or the host name of the mail server you want PHP to use.

Let us know which method you want to use and someone can provide more specific instructions for that method.