我有一個使用SMTP認證使用梨的聯繫表。我想發送確認電子郵件給填寫表格的人。PHP SMTP郵件聯繫表格
我會得到什麼添加到我的PHP來實現這一目標
<?php
error_reporting(E_ALL);
ini_set('display_errors', True);
set_include_path('******');
require_once "Mail.php";
// Set the email variables from the form here:
$name = $_POST['name']; // Pass the Name value to the $Name variable
$number = $_POST['number'];
$email = $_POST['email']; // Pass the Email value to the $Email variable
$enquiry = $_POST['enquiry'];
$comment = $_POST['message']; // Pass the Comment value to the $Comment variable
$from = $email;
$to = "Enquiries <[email protected]>";
$subject = "Enquiry ($enquiry)";
$body = "You have received a Web Enquiry. \n
Name: $name\n
Contact: $number \n
Email: $email\n
Enquiry Type: $enquiry \n
Comments: $comment";
$host = "******.com.au";
$username = "*****.com.au";
$password = "******";
$headers = array('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent! We will be in contact with you shortly!</p>");
}
?>
感謝,
是否需要確認電子郵件或電子郵件副本(如Ivan建議的)? :) –