2014-11-23 88 views
-1

我正在建立一個網站,我希望用戶通過表格給我發電子郵件。
這是我到目前爲止(除了從其他HTML和CSS的):Webform電子郵件與HTML php

<form name="mailform" method="post" action="/assets/php/send_mail.php"> 
    <input type="text" name="name" class="formtext" placeholder="Your name"/> 
    <input type="email" name="email" class="formtext" placeholder="Your email adress"/> 
    <input type="text" name="subject" class="formtext" placeholder="Subject"/> 
    <textarea name="content" placeholder="Message"></textarea> 
    <input type="button" name="send" id="send" value="Send Email" /> 
</form> 

我知道我必須使用PHP,但我是新來的吧。
而且,是的,我想要的主題是:這是一個主題 - 約翰史密斯
我的PHP文件應該怎麼看?
在此先感謝您的幫助!

+1

閱讀手冊http://php.net/manual/en/function.mail.php和谷歌的感覺今天非常有幫助;) – 2014-11-23 16:22:40

回答

0

試試這個:

send_mail.php

$message = "You have a message from {$_POST['name']}. The message is {$_POST['content']}. 

mail("[email protected]", "{$_POST['subject']} - {$_POST['name']}", $message); 

這應該發送電子郵件至你把誰與「自己的學科主題的郵件()函數的第一個參數 - 他們的名字」。

讓我知道,如果這對你有用。

+0

工作得很好!非常感謝! – Villevillekulla 2014-11-24 17:13:35