HTML联系表通过PHP发送邮件 [英] HTML Contact Form Send Mail Through PHP

查看:119
本文介绍了HTML联系表通过PHP发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < form method = post action = sendmail.php> 
< div class = one_third>
< label> Name< / label>
< input type = text name = author value id = name />
< / div>
< div class = one_third>
< label>电子邮件< / label>
< input type = text name = email value id = email />
< / div>
< div class =one_third last>
< label> Subject< / label>
< input type = text name = subject value id = subject />
< / div>
< div class = full_width>
< label>您的邮件< / label>
< textarea name = msg id = msg>< / textarea>
< / div>
< input type = submit name = submit value = Submit />
< / form>

我想知道你是否可以提供一个PHP代码,进入sendmail。

解决方案

首先,您应该尝试在发布问题之前寻找答案,这几乎是第一个谷歌搜索结果php发送邮件将显示你:

 <?php 
if(isset($ _ REQUEST ['email']))
//如果电子邮件被填写,发送电子邮件
{
//发送电子邮件
$ from = $ _REQUEST ['author'];
$ to = $ _REQUEST ['email'];
$ subject = $ _REQUEST ['subject'];
$ message = $ _REQUEST ['msg'];
mail($ to,$ subject,$ message,From:。$ from);

//邮件已发送
echo谢谢您使用我们的邮件表单;
}
else {
//如果email未填写,则显示窗体
//只需关闭php并复制您的表单
的代码? >
- 将您的HTML表单粘贴到此处 -
<?php
}
?>

第二件事是,我不知道你想做什么与你的作者字段。我怀疑你从来没有发过一封电子邮件,您必须输入任何输入字段中的人员。客户端为您做这件事。所以,考虑到这一点,我刚刚在消息的底部留下了作者



这一切都提供了一个工作的电子邮件系统集在php.ini配置设置中。


I have this code for a contact form in html:

 <form method=post action=sendmail.php>
    <div class=one_third>
      <label>Name</label>
      <input type=text name=author value id=name />
    </div>
    <div class=one_third>
      <label>Email</label>
      <input type=text name=email value id=email />
    </div>
    <div class="one_third last">
      <label>Subject</label>
      <input type=text name=subject value id=subject />
    </div>
    <div class=full_width>
      <label>Your Message</label>
      <textarea name=msg id=msg></textarea>
    </div>
    <input type=submit name=submit value=Submit />
  </form>

I would likes to know if you can provide me with a php code, to go inside "sendmail.php" that will actually send the email.

解决方案

First of all, you should try to look for answers before you post questions, this is pretty much what the first result of googling "php send mail" will show you:

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
    //send email
    $from = $_REQUEST['author'] ;
    $to = $_REQUEST['email'] ;
    $subject = $_REQUEST['subject'] ;
    $message = $_REQUEST['msg'] ;
    mail($to, $subject, $message, "From:" . $from);

    // the mail was sent
    echo "Thank you for using our mail form";
}
else {
    //if "email" is not filled out, display the form
    //just close php and copy the code for your form
?>
- paste your html form here -
<?php
}
?>

The second thing is, I don't know what do you want to do with your author field. I suspect you have never sent an email with you having to enter who you are in any input field. The client kind of does that for you. So, with that in mind, I just left author at the bottom of the message.

This all providing you have a working email system set up in php.ini configuration settings.

这篇关于HTML联系表通过PHP发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆