Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHPmailer获取空白电子邮件_Php_Email - Fatal编程技术网

使用PHPmailer获取空白电子邮件

使用PHPmailer获取空白电子邮件,php,email,Php,Email,我已在我的网站主页上创建了此表单- <form action="mail.php" method="post"> <p>Name:</p> <input type="text" name="name" size="40"> <p>Email:</p> <input type="email" name="email" size="40"> <p>Subject:</p> <input

我已在我的网站主页上创建了此表单-

<form action="mail.php" method="post">
<p>Name:</p> <input type="text" name="name" size="40">
<p>Email:</p> <input type="email" name="email" size="40">
<p>Subject:</p> <input type="text" name="subject" size="40">
<p>Message: </p><textarea name="message" rows="6" cols="41"></textarea>
<p><input type="submit" value="Contact Us"></p>
</form>

姓名:

电子邮件:

主题:

信息:

现在我已经在mail.php文件中粘贴了下面的代码。注意,我也在使用phpmailer

<?php
require '/home/hostiojv/public_html/verticaldesign.net/FinalComeagain/phpmailer/class.phpmailer.php';

$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

$mail = new PHPMailer;

$mail->IsSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'p3XXXX.prod.phx3.secureXXXX.net';  // Specify main and backup server
$mail->Port = 465;
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'reply@example.com';                            // SMTP username
$mail->Password = 'XXXX';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable encryption, 'ssl' also accepted
$mail->SMTPDebug = 1;


$mail->From = 'reply@example.com';
$mail->FromName = 'John Smith';
$mail->AddAddress('info@example.com');               // Name is optional

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
$mail->IsHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->Send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}

echo 'Message has been sent';
header("Location: http://verticaldesign.net/FinalComeagain/index.html");
?>

我是PHP新手,而且我知道我没有定义主题或未能从网站主页捕获电子邮件地址

注意:我收到电子邮件,但其中包含“这是粗体的邮件正文”,而且我没有收到我在联系人表单中添加的电子邮件id

另外,我不确定要在这里添加什么-$mail->AddAddress('info@example.com');
因此,我创建了另一封电子邮件,除了reply@example.com..

让我知道我做错了什么


您需要将捕获变量分配给
$mail
对象

$mail->From = $email;
$mail->FromName = $name;
$mail->Body    = $message;
$mail->Subject = $subject;

我不知道该怎么说谢谢你:你刚刚救了我的命day@danishdeb不用担心,很乐意帮忙。