Forum Moderators: coopster

Message Too Old, No Replies

Mailto() Script

Its not sending

         

ffoeg

11:42 am on Mar 5, 2006 (gmt 0)

10+ Year Member



I really don't a lot about PHP at all, but I've written this little php script to send an email from my site. It seems to work fine (no errors show when tested online, but it shows an error:
Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set():
when used on my pc.

The code is shown below:


//GETTING THE VARIOUS DETAILS

//SENDER'S NAME
$name = $_POST['name'];

//SENDER'S EMAIL ADDRESS
$their_email = $_POST['email'];

//SUBJECT OF EMAIL
$subject = $_POST['subject'];

//EMAIL MESSAGE
$message = $_POST['message'];

//DESTINATION EMAIL ADDRESS
$sending_to = "me@example.com";

mail ($sending_to,$subject,$message,"From: $name (['$their_email'])");

//PRINTING THANK YOU
echo "<html>\n
<head>\n
<title>Oven Roast designs :: Thank You!</title>\n
<link href=\"../styles.css\" rel=\"stylesheet\" type=\"text/css\" />\n
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n
</head>";
echo "<body>";
echo "
<table class=\"center\">
<tr>
<td id=\"content-cell\">
Thank you for taking the time to contact us. We will reply to your message as soon as we can.
</td>
</tr>
</table>";
echo "</body>\n
</html>";

The problem is that no email is actually sent, although there are no errors that show.

If anyone can help me, it would be really appreciated!

[edited by: jatar_k at 6:08 am (utc) on Mar. 6, 2006]
[edit reason] generalized [/edit]

dreamcatcher

7:28 pm on Mar 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you set up PHP on your own server, you also need to set up an SMTP server to handle the mail function. This is why you can`t send mail from localhost.

Try this thread:
[webmasterworld.com...]

dc

ffoeg

1:22 pm on Mar 7, 2006 (gmt 0)

10+ Year Member



So...if i had to upload this to my website and try send it using the internet instead of localhost, it should work?

dreamcatcher

1:58 pm on Mar 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should be ok on your production server as they have SMTP setup.

dc

ffoeg

10:20 am on Mar 8, 2006 (gmt 0)

10+ Year Member



Awesome. Thanks!

The server i'm on at the moment doesnt have SMTP support, but thats because its a free hosting plan. Once i upgrade i gain access to an smtp server. :)