Jump to content

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??
Link to comment
https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/
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
Link to comment
https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55082
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);
Link to comment
https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55084
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
Link to comment
https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55237
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.