Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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
Php 使用变量发送电子邮件_Php_Email - Fatal编程技术网

Php 使用变量发送电子邮件

Php 使用变量发送电子邮件,php,email,Php,Email,我一直在寻找我的问题,我知道有一个简单的解决办法,但我就是想不出来,我不断地把头撞在墙上,所以下面是: 我的配置文件中有一个变量 $businessemail = "me@myemail.com"; 这封电子邮件变化很大,所以我想在我的邮件脚本中使用这个变量 //If there is no error, send the email if(!isset($hasError)) { $emailTo = '$businessemail'; //Put your own emai

我一直在寻找我的问题,我知道有一个简单的解决办法,但我就是想不出来,我不断地把头撞在墙上,所以下面是:

我的配置文件中有一个变量

$businessemail = "me@myemail.com";
这封电子邮件变化很大,所以我想在我的邮件脚本中使用这个变量

    //If there is no error, send the email
if(!isset($hasError)) {
    $emailTo = '$businessemail'; //Put your own email address here
    $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments";
    $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

    mail($emailTo, $subject, $body, $headers);
    $emailSent = true;
}
//如果没有错误,请发送电子邮件
如果(!isset($hasError)){
$emailTo='$businessemail';//在此处输入您自己的电子邮件地址
$body=“Name:$Name\n\nEmail:$email\n\n对象:$subject\n\n建议:\n$comments”;
$headers='发件人:我的站点'。“\r\n.”回复:'.$email;
邮件($emailTo、$subject、$body、$headers);
$emailSent=true;
}
}

现在我的问题是如何以正确的方式格式化$businessemail,以便它可以在配置文件中读取消息并将其发送到电子邮件

$businessemail = "me@myemail.com";

谢谢你的帮助。

删除第3行中
$businessemail
的单引号。谢谢你,佩卡,就是这样。。。你在这里真的帮了我:-)
$emailTo = $businessemail; // don't use variable in single quotes here