Jump to content


Photo

send e-mail by php


  • Please log in to reply
4 replies to this topic

#1 10uRrr

10uRrr
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 09 July 2006 - 09:14 AM

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

<!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

<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??

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 09 July 2006 - 10:07 AM

Maybe you should try removing the @ symbol from the front of your call to the mail() function.

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 July 2006 - 12:09 PM

What type of machine are is your server? If it is a local windows box you need to set up an smtp mailer address. Also you really should include a "From:" header and you don't need the double quotes around the variable names in the mail() function.
<?php
$to = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'] ;
$headers = "From: youremail@address.here\n";
mail($to,$subject,$message,$headers);
?>

Ken

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 July 2006 - 12:12 PM

An example of the mail function when the mail is setup on your php.ini ok.

$to = 'bob@barnyard.com';
$subject = 'Wakeup bob!';
$message = '<b>yo</b>, whassup?';
$headers = "From: server@barnyard.com\r\n" .
      'X-Mailer: PHP/' . phpversion() . "\r\n" .
      "MIME-Version: 1.0\r\n" .
      "Content-Type: text/html; charset=utf-8\r\n" .
      "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
mail($to, $subject, $message, $headers);
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 hsncool

hsncool
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 09 July 2006 - 06:36 PM

you have errors all over that thingg!!!

im going to try and see how many i can fynd, hehe!!

okies,

mail.htm
no body tags!
also, why are u using <!-- --> 's ???
use action="sendmail.php"


sendmail.php

if you do use the sender part of ur form, and name it sender..., u can doo ur code like this, and it should work...



<html>
<head>
<title>[b]sendmail[/b]</title>

</head>
[b]<body>[/b]

<?
$to = $_POST['email'];
$sender = $_POST['sender'];
$subject = $_POST['subject'];
$message = $_POST['message'] ;


$email_to = $sender . "<" . $to . ">"

mail($email_to,$subject,$message,"From:my@email.com\n");
     
echo "finished!";
 
 ?>
[b]</body>[/b]
</html>



shud work, tell me if dusnt





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users