2014-01-22 57 views
0

我有非常簡單的HTML表單:發送HTML表單 - 接收空的電子郵件

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

與PHP文件email_ok.php

<?php 
mail('[email protected]', $_POST['name'], $_POST['mail'], $_POST['comment']); ?> <p>OK</p> 

但我仍然接收空郵件。哪裏不對?對不起,我是初學者。

非常感謝。

+0

使用PHPMAILER而不是php的內置郵件() –

+0

http://in1.php.net/manual/en/function.mail.php –

回答

0

修改你的郵件功能,象下面這樣:

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

這樣的:

<?php mail('[email protected]', "Test subject", $_POST['comment']); ?> 

,您可以得到更多的信息:http://in1.php.net/manual/en/function.mail.php

0

我不喜歡這樣

mail($to, $subject, $message, $headers); 
0

您正在使用需要的屬性。我想你正在使用一些JavaScript來使他們需要。當你使用這種類型的東西時,JavaScript代替了你的輸入標籤,你可以檢查你的渲染頁面源代碼。這可能會導致問題,如果它更改您的名稱屬性。

0

試試這個。

$message = $_POST['name'].' '.$_POST['mail'].' '.$_POST['comment']; 
mail('[email protected]', 'Your subject',$message); 

如果你想在$_POST['mail']發送電子郵件,然後用下面。

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

嘗試一下本作,你的PHP代碼

<?PHP 
$email = $_POST["emailaddress"]; 
$to = "[email protected]"; 
$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: [email protected]\n"; 
$usermessage = "Thank you for subscribing to our mailing list."; 
mail($to,$subject,$message,$headers); 
mail($user,$usersubject,$usermessage,$userheaders); 
?> 

如果你需要完整的代碼和HTML以及PHP也讓我。