使用html php的Webform电子邮件

时间:2014-11-23 16:20:51

标签: php html email

我正在建立一个网站,我希望用户通过表单给我发电子邮件。
这是我到目前为止(除了其他HTML和CSS):

<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 个答案:

答案 0 :(得分:0)

试试这个:

send_mail.php

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

mail("whotosendto@domain.com", "{$_POST['subject']} - {$_POST['name']}", $message);

那应该向你输入mail()函数的第一个参数的人发送一封电子邮件,主题是“他们的主题 - 他们的名字”。

请告诉我这是否适合您。