2011-12-21 61 views
0

我有搜索我的問題,我知道有一個簡單的解決方法,但我只是無法弄清楚,我一直在撞牆撞牆,所以在這裏:通過使用變量發送電子郵件

我有一個變量在我的配置文件

$businessemail = "[email protected]"; 

此電子郵件改變了很多,所以我想用這個變量在我的郵件腳本是這樣的

//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; 
} 

}

現在我的問題是我如何格式化以正確的方式在$ businessemail因此它可以讀取和配置文件發送郵件到電子郵件

感謝您的幫助。

+2

刪除第3行'$ businessemail'周圍的單引號。 – 2011-12-21 09:23:26

回答

1
$emailTo = $businessemail; // don't use variable in single quotes here 
+0

謝謝Pekka就是這樣的......你真的幫助我在這裏:-)) – 2011-12-21 09:37:14