添加消息到PHP邮件功能

时间:2015-12-01 09:05:50

标签: php function email

我正在使用这个简单的php邮件功能,我想在邮件中添加另一个文本,例如“此邮件来自网站”。

$email="kontakt@fotografernevesterbro.dk";
$from=$_POST["email"];
$subject=$_POST["subject"];
$message=$_POST["message"] + $sitemessage;
$sitemessage= "this is message from website";

mail ($email, $subject, $message, "From:".$from);

我尝试添加另一个变量并将其放入邮件功能但不起作用。

2 个答案:

答案 0 :(得分:2)

使用.连接(不是+),$sitemessage应在为$message分配值后附加到$email="kontakt@fotografernevesterbro.dk"; $from=$_POST["email"]; $subject=$_POST["subject"]; $sitemessage= "this is message from website"; $message=$_POST["message"] . $sitemessage; mail ($email, $subject, $message, "From:".$from);

checkUsage() {
  while true; do
    sleep 15
    fileSize=$(stat -c%s $1)

    sleep 10;
    fileSizeNew=$(stat -c%s $1)

    if [ "$fileSize" == "$fileSizeNew" ]; then
      echo -e  "[Error]: No activity noted on this window from 5 sec. Exiting..."
      kill -9 $$
    fi
  done
}

答案 1 :(得分:-1)

此代码将完全按照您的意愿执行。

  $email="kontakt@fotografernevesterbro.dk";
    $from=$_POST["email"];
    $subject=$_POST["subject"];
    $headers = "From: $from  ";
    $message=$_POST["message"];
    $message .= " this is message from website";

    mail ($email, $subject, $message, $headers);