e-mail by php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
10uRrr
Forum Newbie
Posts: 8
Joined: Sun Jul 09, 2006 4:48 am

e-mail by php

Post 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]
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

actionfiltered="sendmail.php
I think this should be action="sendmail.php"
10uRrr
Forum Newbie
Posts: 8
Joined: Sun Jul 09, 2006 4:48 am

Post 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
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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.
10uRrr
Forum Newbie
Posts: 8
Joined: Sun Jul 09, 2006 4:48 am

Post 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
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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.
10uRrr
Forum Newbie
Posts: 8
Joined: Sun Jul 09, 2006 4:48 am

Post 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??
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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.
10uRrr
Forum Newbie
Posts: 8
Joined: Sun Jul 09, 2006 4:48 am

Post by 10uRrr »

it is already port 25 and localhost. but not working, may I use gmail like as a smtp server??
Post Reply