Jump to content

Archived

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

10uRrr

send e-mail by php

Recommended Posts

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

Share this post


Link to post
Share on other sites
Maybe you should try removing the @ symbol from the front of your call to the mail() function.

Share this post


Link to post
Share on other sites
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.
[code]<?php
$to = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'] ;
$headers = "From: youremail@address.here\n";
mail($to,$subject,$message,$headers);
?>[/code]

Ken

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
you have errors all over that thingg!!!

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

okies,

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


[b]sendmail.php[/b]

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


[code]

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

[/code]


shud work, tell me if dusnt

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.