使用 phpmailer 使用邮件地址的帖子数据发送电子邮件
我正在尝试根据 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 = "[email protected]";
$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";
}
?>
im trying to email something to a user based on the email address that is entered on the html form. i am using post as the method and i cant figure out how to use that data for the email address using 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 = "[email protected]";
$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";
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
表单编辑:(
删除双引号)
php 编辑:
应该可以完成这项工作。
form edit:
(removed the double quote)
php edit:
should do the job.