Jump to content

Archived

This topic is now archived and is closed to further replies.

yaqub

I'm new with PHP can someone please help me out with something?

Recommended Posts

Hi-

I'm trying to make a simple mail form using dreamweaver and when I preview the page I get 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:\Program Files\Apache Group\Apache2\htdocs\newland\message_sent.php on line 6

I'm not sure what to do here. I want to make sure that I'm headed in the right direction so can someone please let me know how or what I can change to make this work.

Also here's the dreamweaver code::

<?php
$to = "yaqoobcerbes@hotmail.com";
$subject = "This is the message subject";
$body = "This is the message body";
$headers = "From: yaqoobcerbes@hotmail.com\n";
mail($to,$subject,$body,$headers);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Newland Tours: About</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/newland.css" rel="stylesheet" type="text/css" />
</head>

<body>
<a href="#top"><img src="images/spacer.gif" alt="Skip to main image" width="1" height="1" border="0" align="left" /></a>
<table width="750" border="0" cellpadding="3" cellspacing="0">
<tr>
  <td><img src="images/banner_left.gif" alt="Newland Tours Banner" width="451" height="68" /></td>
  <td width="280"><img src="images/banner_right.jpg" alt="Newland Tours Banner, previous tour images" width="276" height="68" /></td>
</tr>
<tr>
  <td><img src="images/navbar.gif" name="navbar" alt="Newland Tours image" width="450" height="20" border="0" usemap="#navbarMap" /></td>
  <td><img name="copyright_bar" src="images/copyright_bar.gif" alt="Copyright 2006 Newland Tours width="272" height="20" border="0" /></td>
</tr>
<tr>
  <td colspan="2">
<h1><br />
  <a name="top" id="top"></a>Message Sent  </h1>
    <p>Your message has been sent. We will contact you soon.</p>
    <p>Return to Newland <a href="index.php">home</a>.  </p></td>
</tr>
</table>

<br />
<br />


<map name="navbarMap" id="navbarMap">
<area shape="rect" coords="1,0,62,20" href="index.php" alt="Home" />
<area shape="rect" coords="71,0,117,20" href="about.php" alt="About" />
<area shape="rect" coords="129,0,196,20" href="tours.php" alt="Find Tours" />
<area shape="rect" coords="209,0,311,20" href="profiles.php" alt="Navigation Bar" />
<area shape="rect" coords="327,0,434,20" href="contact.php" alt="Contact An Agent" />
</map>
</body>
</html>

Please give me a hand with this, it's much appreciated.

Ya'qub :D

Share this post


Link to post
Share on other sites
Are you actually using a mail server on your local host.  Also check your php.ini file to check if your using the right SMTP settings

Share this post


Link to post
Share on other sites
I'm new. So I'm using Apache and I have looked at the php.ini file I think. Can someone give me some step by step advice instaed of just saying have you done this or that? I'm new so for me to mess with the .ini file I would need some type of assistance.

Thanks

Share this post


Link to post
Share on other sites
How do I check the SMTP settings and how do I change them? I'm using QK SMTp server I hope someone can please walk me through this step by step.

I'm having a really hard time trying to find help which is really surprising, I thought that people formed a rather tight community to help newbies get up and started.

Please anyone who's ever had this problem please walk me through what I got to do here. I know this is a common problem so everyone has gone through at one point in time.

Thanks

Share this post


Link to post
Share on other sites
I think this is where I have to specify what server I'm using isn't it? From the error message it says that it's unable to find a mail server.

You tell me, I think it's basically saying I have reconfig the php.ini file to reflect what mail server I'm using. But I'm having trouble finding it(I installed apache to the default location so you should know exactly where that file is). I downloaded and installed QK SMTP mail server which is running also Apache is running obviously by the error message.

So do you have some ideas for me? I know this is a commone problem especially for newbies.

Thanks

Share this post


Link to post
Share on other sites
Wow. I'm surprised no one knows about this issue. I really thought people would maybe offer a little more help to a newbie php'er

Disappointed

Share this post


Link to post
Share on other sites
is the smtp server on the same computer as the apache server? is it running correctly? if you want to test the server, you can send an email with MS Outlook or MS Exchange using that smtp server and make sure that it's working properly.

you also want to see if windows firewall is configured correctly for the server and port 25. go to Control Panel->Windows Firewall->Exceptions.

Share this post


Link to post
Share on other sites
Create a script with this line in it:
[code]<?php phpinfo(); ?>[/code]
and bring it up. In the output will be the location of the PHP.INI file

Ken

Share this post


Link to post
Share on other sites
on windows look in C:\WINDOWS for the php.ini

find:
[mail function]
; For Win32 only.
SMTP = mail.yourhost.com <----use the mailserver from your isp

; For Win32 only.
sendmail_from = admin@yourhost.com <-- pick 1 of your emails that runs on the isp server

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =




dont forget to reboot your apache... if not now how.. just reboot windows

Share this post


Link to post
Share on other sites
you can also use ini set...

<?php
ini_set("sendmail_from", "myemail@myhost.com");
ini_set("SMTP", "mail.yourhost.com");
ini_set("smtp_port", 25);
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.