将php电子邮件表单修改为smtp电子邮件表单

时间:2014-04-14 14:44:18

标签: php html forms email smtp

嗨,我有一个自包含的电子邮件表单,所以它不需要任何其他脚本我遇到问题,我需要它通过smtp发送它但我见过的例子超过我的技能水平我是想知道是否有人可以帮助我

我的电子邮件表单是:

<html> 
<head>
<!--[if !IE]><!-->
<link rel="stylesheet" type="text/css" href="Register.css">
<!--<![endif]-->
</head>
<body style="background-color:#303030">
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"]))
    {
?>
    <div id="login">
    <form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
       <input type="hidden" name="subject" value="can you create me an account"><br/>
       Message: <textarea rows="10" cols="40" name="message"></textarea><br/>
       first <input type="text" name="first_name" ><br/>
       last <input type="text" name="last_name" ><br/>
       company <input type="text" name="company" ><br/>
       email <input type="text" name="email" ><br/>
       Telephone number <input type="text" name="telnr" ><br/>
       Description <input type="text" name="Description" ><br/>
       <input type="submit" name="submit" value="Submit Feedback">
    </form>
    </div>  

<?php 
    }
    else
  // the user has submitted the form
    {
  // Check if the "subject" input field is filled out
    var_dump($_POST);
if (isset($_POST["subject"]))
    {
        $subject = $_POST["subject"];
        $message = $_POST["message"];
        $first = $_POST["first_name"];
        $last = $_POST["last_name"];
        $company = $_POST["company"];
        $email = $_POST["email"];
        $telnr = $_POST["telnr"];
        $description = $_POST["Description"];
        $therest = "First name= $first" . "\r\n" . "Last name= $last" . "\r\n" . "Company= $company" . "\r\n" . "Email= $email" . "\r\n" . "Telnr= $telnr" . "\r\n" . "Description= $description";          
    }
        echo "$therest <br>";
        $message = wordwrap($message, 700);
        $first = wordwrap($first, 70);
        $last = wordwrap($last, 70);
        mail("receiver@whatever.co.uk",$subject,$name,$therest,"subject: $subject\n");
        echo "Thank you for sending us feedback";
    }
?>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

对此的答案是没有这个表单无法更改为SMTP电子邮件表单,我需要做的是创建一个使用PHPMailer的表单,然后我添加了我需要的输入框这添加了更多开发到网站,但它实际上是在我试图达到的服务器上工作