phpmailer未定义变量
嗨,我收到了这个erorrs,但我不知道问题出在哪里。 如有任何建议,我将不胜感激 注意:未定义的变量:C:\wamp\www\restaurace\kongresform.php第59行的标题 注意:未定义的变量:C:\wamp\www\restaurace\kongresform.php中的messageb,第72行phpmailer未定义变量,php,phpmailer,Php,Phpmailer,嗨,我收到了这个erorrs,但我不知道问题出在哪里。 如有任何建议,我将不胜感激 注意:未定义的变量:C:\wamp\www\restaurace\kongresform.php第59行的标题 注意:未定义的变量:C:\wamp\www\restaurace\kongresform.php中的messageb,第72行 if (empty($errors)) { //If everything is OK // send an email // Obtai
if (empty($errors)) { //If everything is OK
// send an email
// Obtain file upload vars
// Headers
$headers.= "From: $emailfr \n";
$headers.= "BCC: $emailcc ";
// creates a boundary string. It must be unique
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
"boundary=\"{$mime_boundary}\"";
$messageb.="Dobrý den,<br>\n";
$messageb.="Jméno a přijímení: <b>".$namefrom."</b><br>\n";
$messageb.="Email: <b>".$email."</b><br>\n";
$messageb.="Prostor pro poznámky: ".$message."<br><br>\n";
$messageb.="S pozdravom<br>\n";
$messageb.="tým Fincentrum Reality<br>\n";
$messageb.="<br>\n";
$messageb.="========================================================================<br>\n";
$messageb.="Tento e-mail byl odeslaný automaticky z webu. Prosím, neodpovídejte na něj.<br>\n";
$messageb.="========================================================================<br>\n";
$subject="Potvrzení\n";
// PHP Mailer
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mattoni.resta.test@gmail.com'; // SMTP username
$mail->Password = 'mattonirestaurace'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom($emailfr);
$mail->addAddress($to); // Add a recipient
//$mail->addReplyTo('webform@fincentrum.com', 'Information');
//$mail->addCC($emailcc);
$mail->addBCC($emailcc);
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$mail->Body = $messageb;
$mail->CharSet = 'UTF-8';
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
exit("Mail could not be sent. Sorry! An error has occurred, please report this to the website administrator.\n");
//echo 'Mailer Error: ' . $mail->ErrorInfo;
}
else {
echo '<div id="formfeedback"><h3>Děkujeme za Vaší zprávu!</h3><p>'. $thanksmessage .'</p></div>';
unset($_SESSION['yellloForm']);
print_form();
} // end of if !mail
}
if(空($errors)){//如果一切正常
//发送电子邮件
//获取文件上载变量
//标题
$headers.=“发件人:$emailfr\n”;
$headers.=“密件抄送:$emailcc”;
//创建边界字符串。它必须是唯一的
$semi_rand=md5(time());
$mime_boundary=“==Multipart_boundary_x{$semi_rand}x”;
//添加文件附件的标题
$headers.=“\n时间版本:1.0\n”。
“内容类型:多部分/混合;\n”。
“边界=\”{$mime\u boundary}\”;
$messageb.=“多布尔登,
\n”;
$messageb.=“Jméno a přijímeni:”.$namefrom.“
\n”;
$messageb.=“电子邮件:”..$Email.“
\n”;
$messageb.=“Prosor pro poznámky:”.$message.“
\n”;
$messageb.=“S pozdravom
\n”;
$messageb.=“tým Fincentrum Reality
\n”;
$messageb.=“
\n”;
$messageb.=“===========================================================================================================================================
\n”;
$messageb.=“odeslanýautomaticky z webu.Prosím,neodpovídejte na něj.
\n”;
$messageb.=“===========================================================================================================================================
\n”;
$subject=“Potvrzení\n”;
//PHP邮件程序
$mail=新的PHPMailer;
//$mail->SMTPDebug=3;//启用详细调试输出
$mail->isSMTP();//设置邮件程序以使用SMTP
$mail->Host='smtp.gmail.com';//指定主smtp服务器和备份smtp服务器
$mail->SMTPAuth=true;//启用SMTP身份验证
$mail->Username='mattoni.resta。test@gmail.com“;//SMTP用户名
$mail->Password='mattonirestaurace';//SMTP密码
$mail->SMTPSecure='tls';//启用tls加密,也接受'ssl'
$mail->Port=587;//要连接的TCP端口
$mail->setFrom($emailfr);
$mail->addAddress($to);//添加收件人
//$mail->addReplyTo('webform@fincentrum.com","信息",;
//$mail->addCC($emailcc);
$mail->addBCC($emailcc);
//$mail->addAttachment('/var/tmp/file.tar.gz');//添加附件
//$mail->addAttachment('/tmp/image.jpg','new.jpg');//可选名称
$mail->isHTML(true);//将电子邮件格式设置为HTML
$mail->Subject=$Subject;
$mail->Body=$messageb;
$mail->CharSet='UTF-8';
//$mail->AltBody='这是非HTML邮件客户端的纯文本正文';
如果(!$mail->send()){
退出(“邮件无法发送。抱歉!发生错误,请向网站管理员报告。\n”);
//回显“邮件错误:”。$mail->ErrorInfo;
}
否则{
echo'Děkujeme za Vašzprávu!。$thanksmessage.;
取消设置($_会话['yelloform']);
打印表单();
}//如果!邮件结束
}
这是:
$headers.= "From: $emailfr \n";
与此相同:
$headers = $headers . "From: $emailfr \n";
其中包括:
$headers . "From: $emailfr \n";
但是,当时,$headers
尚未定义。因此会出现错误,因为您试图从一个不存在的变量中读取
只需修改使用$headers
的第一个实例来定义它,而不是尝试使用它:
$headers = "From: $emailfr \n";
对第一行的
$messageb
重复此操作,它也会被使用。他试图将一个值附加到一个尚未初始化的变量
改变
$headers.= "From: $emailfr \n";
到
及
$messageb.=“Dobrýden,
\n”;
到
$messageb=“Dobrýden,
\n”;
在附加变量之前,不需要初始化变量。你需要把每一行中的第一行作为=
而不是=
“在第一行重复$messageb,它也会被使用。”-当他们必须自己做这项工作并自己解决时,这确实是一种方法,而不是用勺子喂他们;-)回答得好,大卫。那么告诉我们,他们为什么要这么做?你知道有一个原因;告诉我们吧。他试图给一个尚未初始化的变量附加一个值。别告诉我(我已经知道“为什么”)。你在评论中说的话原本应该是你答案的一部分。Stack pro提示:在发布答案(可能的解决方案)时,一开始就“狠狠一击”,将吸引正面选票;如果你喜欢的是那些。
$headers = "From: $emailfr \n";
$messageb.="Dobrý den,<br>\n";
$messageb ="Dobrý den,<br>\n";