0

此脚本的目的是发送一封电子邮件,但它不会包含您的姓名和电子邮件,而是将其包含在消息中,因为该网站已经从 PHP 会话中获得了有关此内容的详细信息。目前“2Email”工作..它可以向收件人的邮箱发送消息,并包含用户输入的消息。但它不遵循模板。IE 它不包括文本“通过仪表板发送”

<?php

session_start();
if(!isset($_SESSION["USER"])){
    header("Location: ../login.php?NotAuth");
}


 $to = $_POST['2Email'];
 $name = $_SESSION["USER"]["FullName"]; 
 $email = $_SESSION["USER"]["Email"];
 $subject = $_POST['regarding'];
 $message = $_POST['msg'];
 $Cc= $_SESSION["USER"]["Email"];
 $headers = "From: $email";
 $tracker = "This message was sent via the TrackerSystem dashboard";


$message = "Hi, "."\n".$message. "\n". "Regards, ".$name. "\n".$tracker. 
 $sent = mail($to, $subject, $message, $headers) ; 
 if($sent) {
     print "Sent successfully! XD "; 
    } else {
         print "The server made a booboo, the email didn't send :'( "; 
    } 


    ?>
4

1 回答 1

1

是不是第 19 行的错字:"\n".$tracker.?如果是这样,这就是阻止您tracker被附加到消息的原因。

实际发生了什么:第 19-20 行的整个表达式(这个):

$message = "Hi, "."\n".$message. "\n". "Regards, ".$name. "\n".$tracker. 
   $sent = mail($to, $subject, $message, $headers) ; 

正在从右到左进行评估(如果它甚至有效,我对此表示怀疑)。因此(第一)发送邮件并将结果分配给$sent(第二)将整个连接字符串分配给$message

要修复它,请制作"\n".$tracker. "\n".$tracker;.

于 2012-07-22T10:48:27.720 回答