0

I have very simple HTML form:

<form action="email_ok.php" method="post" enctype="text/plain"> 
Name:<br>
<input type="text" name="name" value="" size="50" required>
Email:<br>
<input type="text" name="mail" value="@" size="50" required><br>
Comment:<br>
<input type="text" name="comment" value="" size="50" required><br><br>
<input type="submit" value="SEND">
<input type="reset" value="Delete">
</form>

with php file email_ok.php

<?php
mail('myemail@mail.com', $_POST['name'], $_POST['mail'], $_POST['comment']); ?> <p>OK</p>

But I am still receiving empty mail. What is wrong? Sorry I am beginner.

Thanks a lot.

WanderRook
  • 81
  • 1
  • 10

6 Answers6

0

modify you mail function like below:

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

like this:

<?php mail('myemail@mail.com', "Test subject", $_POST['comment']); ?>

You can get more info :http://in1.php.net/manual/en/function.mail.php

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
0

i do it like this

mail($to, $subject, $message, $headers);
Robin
  • 392
  • 1
  • 2
  • 12
0

look at this. remove the enctype in the form-tag and it should work.

PHP cannot handle data which is sent with enctype "text/plain".

method="post" enctype="text/plain" are not compatible?

Community
  • 1
  • 1
leuchtdiode
  • 477
  • 3
  • 12
0

You are using an attribute required. I guess you are using some javascript to make them required. When you use that kind of thing, javascript replaces your input tags, you can check your rendered page source. This may cause the problem if it changes your name attribute.

Kuzgun
  • 4,649
  • 4
  • 34
  • 48
0

Try this.

$message = $_POST['name'].' '.$_POST['mail'].' '.$_POST['comment'];  
mail('myemail@mail.com', 'Your subject',$message);

If you want to send email on $_POST['mail'] then use following.

$message = $_POST['name'].' '.$_POST['mail'].' '.$_POST['comment'];  
mail($_POST['mail'], 'Your subject',$message);
Shahid Ahmed
  • 494
  • 2
  • 4
  • 10
0

try this for you php code

<?PHP
$email = $_POST["emailaddress"];
$to = "you@youremail.com";
$subject = "New Email Address for Mailing List";
$headers = "From: $email\n";
$message = "A visitor to your site has sent the following email address to be added to your mailing list.\n

Email Address: $email";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: you@youremailaddress.com\n";
$usermessage = "Thank you for subscribing to our mailing list.";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
?>

if you need full code with html as well as php also let me .

Ferrakkem Bhuiyan
  • 2,741
  • 2
  • 22
  • 38