PHP邮件使用SMTP从HTML表单获取信息

I've recently moved hosts and now with the contact form I have to use SMTP. I have been able with some help get something to work but am unable to retrieve the information I need from the form. The information I am trying to pull is name email phone and message. This is what I have been using

<?php

require "email.php";

$mail = new EMail;
$mail->Username = 'username.co.uk';
$mail->Password = 'mypassword';

$mail->SetFrom("no-reply@mywebsite.co.uk","no-reply@mywebsite.co.uk");  // Name is      optional
$mail->AddTo("no-reply@mywebsite.co.uk","no-reply@mywebsite.co.uk"); // Name is optional
$mail->Subject = "Hello World Again!";
$mail->Message = "Hello World!";

//Optional
$mail->ContentType = "text/html";          // Defaults to "text/plain; charset=iso-8859-1"
$mail->Headers['X-SomeHeader'] = 'abcde';  // Set some extra headers if required
$mail->ConnectTimeout = 30;  // Socket connect timeout (sec)
$mail->ResponseTimeout = 8;  // CMD response timeout (sec)
$success = $mail->Send();

?>

When I test this an email gets sent but of course only the "Hello World" text gets sent as I'm unsure where to put the necessary code to pull the info I need.

Prior to moving hosts and not needing SMTP I was using this script

<?php

//-----------------------------------------------------
//-----------------------------------------------------
$address= "myemail.co.uk";
//-----------------------------------------------------
//-----------------------------------------------------

$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$message_content =        $_REQUEST["message"];
$mime_boundary = md5(time());

$headers = "From: $name   <$email>
";
$headers .= "Reply-To: $subject <$email>
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type:   multipart/alternative;   boundary=\"$mime_boundary\"
";

$message = "--  $mime_boundary

";
$message .= "New email from the  Commons website: 


";
$message .= "Name: $name 

";
$message .= "Email: $email 

";
$message .= "Phone: $phone 

";
$message .= "Message:     $message_content 

";

$message .= "--$mime_boundary--

";

$mail_sent = mail($address,   $subject, $message, $headers);
echo $mail_sent ? "Success, mail   sent!" : "Mail failed";
?>

Thanks in advance

Kind Regards

Tim

Did u try as this way???

 $message_str = str_replace("[first_name]", $fname, $message_str);
                            $message_str = str_replace("[last_name]", $lname, $message_str);
                            $message_str = str_replace("[site_name]", "RMS", $message_str);

// Always set content-type when sending HTML email
                            $headers = "MIME-Version: 1.0" . "
";
                            $headers .= "Content-type:text/html;charset=UTF-8" . "
";

// More headers
                            $headers .= 'From: <norply@rms.com>' . "
";


                            $subject = "activate account!";
                            if (mail("asd@sad.com", $subject, $message_str, $headers)) {
                                echo"Email successfully sent!";
                            } else {
                                echo"Email delivery failed…";
                            }

Just USe Php Mail function

consider below code

$subject = 'Welcome To demo.com';

    $mydata['name'] = 'demo';
    $mydata['user_name'] = 'test1';
    $mydata['email'] = test@gmail.com;
    $mydata['password'] = $password;
    $mydata = (object)$mydata;
                $message = "<div style='height: 500px; background: none repeat scroll 0% 0% rgb(241, 241, 241); border: 1px solid rgb(6, 106, 117); width: 450px;'>
                <div style='width: 100%; background: none repeat scroll 0% 0% rgb(6, 106, 117); height: 80px;'>
                <div style='width:150px; height:100px;margin:8px; float:left'>
                </div>
                </div>
                  <div style='width:100%;height:360px; margin: auto; float:left; text-align: center;'>
                  <h2>Hello $mydata->name </h2>

                  <h3>Here is you login details for Demo</h3>
                  <br>
                  <h3>Username: $mydata->user_name</h3>

                  <h3>Password: $mydata->password</h3>
                  </div>
                  <div style='height:30px;padding-top:10px;float:left; width:100%;text-align:center;background:#1d5770;'>
                    <span style='color:#fff;font-weight:bold'>demo Team</span>
                  </div>
                </div>";
    //$message = "<br><br>Username:$mydata->user_name <br><br><br>Password:$mydata->password <br>";

    $headers  = 'MIME-Version: 1.0' . "
";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
    $headers .= "To: $mydata->name <$mydata->email>" . "
";
    $headers .= "From: demo.com <contact@demo.com>" . "
";

    mail($mydata->email, $subject, $message, $headers);

for further reference follow these links

http://www.w3schools.com/php/php_ref_mail.asp
http://php.net/manual/en/function.mail.php

I used this however the message I get is that the email failed

<?php

require "email.php";

$mail = new EMail;
$mail->Username = 'myemail.co.uk';
$mail->Password = 'password';

$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$message_content =        $_REQUEST["message"];
$mime_boundary = md5(time());

$headers = "From: $name   <$email>
";
$headers .= "Reply-To: $subject <$email>
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type:   multipart/alternative;   boundary=\"$mime_boundary\"
";

$message = "--  $mime_boundary

";
$message .= "New email from the  Commons website: 


";
$message .= "Name: $name 

";
$message .= "Email: $email 

";
$message .= "Phone: $phone 

";
$message .= "Message:     $message_content 

";

$message .= "--$mime_boundary--

";

echo $mail_sent ? "Success, mail   sent!" : "Mail failed";

?>