<html>
<form method="post" action="email.php">
Email: <input name="email name" id="email" type="text" /><br/>
Message:<br/><text area name="message" id="message" rows="15" cols="40</text area><br>
<input type="submit" value="Submit" />
</form>
<html/>
我有這些代碼,我想發送電子郵件到[email protected]聯絡表格上,但它說,至少輸入一個收件人和發送當我輸入電子郵件至$郵件 - >添加地址($電子郵件)如果我更改爲$ mail-> addadress([email protected])即使表單上的電子郵件與默認不同,它會發送到[email protected]請幫助我。如何聯繫表上使用的PHPMailer
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
require("PHPMailerAutoload.php");
require "class.phpmailer.php";
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Host = "smtp.gmail.com";
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "*************"; // SMTP password
$mail->AddAddress=$email;
$mail->IsHTML(true);
$mail->Subject = "You have received feedback from your website!";
$mail->Body = $message;
$mail->AltBody = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
'addAddress'是PHPMailer的類中的一個函數,所以你需要通過所需的電子郵件作爲參數。 – MonkeyZeus