現在我有這樣的:
$sendtoname = "John";
$sendtoemail = "[email protected]";
而且這樣的:
$message = "Dear ".$sendtoname;
$message .= ",<br><br>A new volunteer has registered for your ".$_REQUEST['pickevent'];
所以,我收到一條消息,說,
"Dear John,
A new volunteer has registered for your event..."
但「約翰」沒有出現;它顯示空白。我該如何糾正?
編輯:
好吧,這裏是我的全碼:
<?php
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
//send an email from the server TO YOUR EMAIL
$fromname = $_REQUEST['firstname'];
$fromemail = $_REQUEST['email'];
$subject = "NMVN EVENT REGISTRATION";
$message = "Dear ".$sendtoname;
$message .= ",<br><br>A new volunteer has registered for your ".$_REQUEST['pickevent'];
$message .= " event. Below is a copy of their registration: ".$_REQUEST['blank'];
$message .= " <br><br><br> <b>First Name:</b> ".$_REQUEST['firstname'];
$message .= " <br> <b>Last Name:</b> ".$_REQUEST['lastname'];
$message .= " <br> <b>Cell Phone:</b> ".$_REQUEST['cellphone'];
$message .= " <br> <b>Alternative Phone:</b> ".$_REQUEST['altphone'];
//This is the person who is going to receive the email
switch ($_REQUEST["pickevent"])
{
case 'Heart Walk 4/20/13':
$sendtoname = "Bob";
$sendtoemail = "[email protected]";
break;
case 'Bowling Fundraiser 5/4/13':
$sendtoname = "John";
$sendtoemail = "[email protected]";
break;
}
//Email header stuff
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $fromname <$fromemail>\r\n";
$headers .= "To: $sendtoname <$sendtoemail>\r\n";
$headers .= "Bcc: [email protected]" . "\r\n";
$headers .= "Reply-To: $fromname <$fromemail>\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
$headers .= "X-Mailer: Created by Mike Gandy";
//this next line creates and sends the email
mail($sendtoemail, $subject, $message, $headers);
?>
形式得到正確響應,否則,而它被髮送到正確的人,並密送給我。所有其他信息也能正常工作。唯一不起作用的是$ sendtoname沒有出現在消息中。儘管如此,它出現在標題中。
對不起?約翰是否出現在信息中? – andrewsi 2013-04-11 17:58:32
不,約翰在我收到郵件時沒有出現在郵件中。 – 2013-04-11 18:00:36
在您創建'$ message'的地方是否可以看到'$ sendtoname'?在函數中創建'$ message'還是'$ sendtoname'? – Pietu1998 2013-04-11 18:00:38