Page 1 of 1

e-mail by php

Posted: Sun Jul 09, 2006 4:53 am
by 10uRrr
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hi everybody;
I have a question, I want to send an e-mail by php, the is working but not send I could not find my error if you, tell answer me pls..

mail.htm

[syntax="html"]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>mail</title>

</head>


<form method="post" actionfiltered="sendmail.php">
 <td>To:<input name="email" type="text" /></br></br></td>
 
<!-- Sender: <input name="email" type="text" /></br></br> -->
 
<td> Subject: </br>
 <textarea name="subject" cols="15" rows="2"> </textarea></br></td>
 
 <td> Message: </br>
  <textarea name="message" rows="15" cols="40">
  </textarea><br /></td>
 
  <input type="submit" />
  </form>

</html>
sendmail.php[/syntax]

Code: Select all

<html>
<head>
<title>senmail</title>

</head>


<?
   $to = $_POST['email'];
  // $sender = $_POST['sender'];
   $subject = $_POST['subject'];
   $message = $_POST['message'] ;
  
  // $headers = "From: localhost\n";
      //ini_set("SMTP", "localhost");
   @mail( "$to" , "$subject" , "$message");
     
    echo "finished!";
 
 ?>

</html>
where is the error??


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Jul 09, 2006 4:56 am
by jamiel
Take the @ away and see what error you are getting. Also do a print_r($_POST) and make sure everything is set the way you want it.

Posted: Sun Jul 09, 2006 4:57 am
by matthijs
actionfiltered="sendmail.php
I think this should be action="sendmail.php"

Posted: Sun Jul 09, 2006 4:59 am
by 10uRrr
if I take @ I recieve an error message like as:
mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in c:\inetpub\wwwroot\sendmail.php on line 16

Posted: Sun Jul 09, 2006 5:02 am
by jamiel

Code: Select all

$headers = "From: Your Name <email>";

mail($to, $subject, $message, $headers);
Try that, you need the from header. replace e-mail with your reply address etc.

Posted: Sun Jul 09, 2006 5:06 am
by 10uRrr
and now ;I have :lol:

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:\inetpub\wwwroot\sendmail.php on line 17

Posted: Sun Jul 09, 2006 5:08 am
by jamiel
Do you have SMTP running on your machine?

XP : Control Panel -> Administrative Tools -> Services -> Simple Mail Transfer Protocol (SMTP) -> Start

Otherwise in your php.ini you need to put the SMTP details of your ISP or hosting company.

Posted: Sun Jul 09, 2006 5:12 am
by 10uRrr
yes smtp server is running on localhost. but I didnt understand wht it gives an error like as. to check could you tell me what smtp details sould I put pls??

Posted: Sun Jul 09, 2006 5:21 am
by jamiel
If its on your machine then localhost port 25 should work if you have left all your SMTP configuration as default. Try and telnet localhost 25 , to make sure its really running.

Posted: Sun Jul 09, 2006 5:30 am
by 10uRrr
it is already port 25 and localhost. but not working, may I use gmail like as a smtp server??