使用phpmailer发送电子邮件,使用post数据作为电子邮件地址


emailing using phpmailer using post data for email address

我试图根据在HTML表单上输入的电子邮件地址向用户发送电子邮件。我使用post作为方法,我不知道如何使用phpmailer的电子邮件地址使用该数据。

<!DOCTYPE html>
<html>
<form method='post'>
<input type='email' value='@domain.com' name='emailaddress'>
<input type='submit' value='submit' name='submit'> 
</form>
</html>
<?php
if (isset($_REQUEST['Submit'])) {
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail-> IsSMTP();
$mail->Host = "mail.domain.com";
$mail->Username = 'username';
$mail->Password = 'password';
$mail->From = "foo@bar.com";
$mail->FromName = "foo bar";
$mail->AddAddress = (HERE IS WHERE I WANT TO ENTER emailaddress FROM THE FORM);
$mail->Subject = "test1";
$mail->Body = "Test 1 of PHPMailer.";
$mail->IsHTML(true);
$mail->Port = 25;
$mail->AddAttachment('sample.pdf','sample.pdf');
//$mail->SMTPSecure = 'ssl';
if(!$mail->Send())
{
echo "Message did not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";

}
?>

form edit:

<input type='email' value='@domain.com' name='emailaddress'>
(去掉双引号) php编辑:

$mail ->AddAddress = $_POST['emailaddress'];