2016-06-24 4 views
-2

私は私のウェブサイトの訪問者を持っている必要がありますどのように私は、GET/POSTのクエリでは?PHPを使ってフォームデータをメッセージとしてどのように送信しますか?

+2

[セの可能性のある重複PHPページからGMail SMTPサーバを使って電子メールを送信する](http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page) – PacMan

+3

可能な重複[同じスクリプトで送信時にHTMLフォームからPHPでメールを送信](http://stackoverflow.com/questions/18379238/send-email-with-php-from-html-form-on-submit-with-the -same-script) – UditS

答えて

0

これを行うことができるようになります。PHPを経由して、私のメールに、コンタクトフォームとして(フォームデータを送信し、タグ html forms/w3schools を使用して例えば

.html page: 
<form method="GET" action="send.php"> 
<input name="fieldname" type="text" placeholder="You text here..."> 
<input type="submit" value="Submit"> 
</form> 

send.php 
<?php 

if (isset($_GET['fieldname']) { 
    // you code here.. 
} 

例(機能メールで電子メールを送信する)
about mail() function on php.net

$from = '[email protected]'; 
$to = '[email protected]'; 
$subject = 'your subject'; 
$message = 'your<br>message<br>in html code'; 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= "Content-type: text/html; charset=utf-8 \r\n"; 
$headers .= 'To: Author <' .$to . ' >' . "\r\n"; 
$headers .= 'From: '.$author.' <'.$from.'>' . "\r\n"; 
mail($to, $subject, $message, $headers); 
関連する問題