是否可以將我的mailto收件人設置爲$ email字符串? 我在我的網站上有一個預訂表格,我希望在郵件中有2個按鈕(Accept/Decline)。這些按鈕應該自動打開一個新的電子郵件窗口,其中包含表單中的設置正文和收件人電子郵件。我的問題是,我不能從表單中的電子郵件到mailto按鈕。我可以將mailto的收件人設置爲一個php字符串嗎?
一些幫助將是不錯:)
<?php
include dirname(dirname(__FILE__)).'/mail.php';
error_reporting (E_ALL^E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post){
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$phone = stripslashes($_POST['phone']);
$amount = stripslashes($_POST['amount']);
$date = stripslashes($_POST['date']);
$time = stripslashes($_POST['time']);
$message .= "Telefonnummer: ".$phone."\n<br />"."Personen: ".$amount."\n<br />"."Datum: ".$date."\n<br />"."Uhrzeit: ".$time."\n<br />";
$message .= '<html><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="mailto:<?php $email?>?Subject=Reservierung 73BB&Body=Hiermit bestaetigen wir Ihre Reservierung in der ...." target="_blank" style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; background-color: #EB7035; border-top: 12px solid #EB7035; border-bottom: 12px solid #EB7035; border-right: 18px solid #EB7035; border-left: 18px solid #EB7035; display: inline-block;">Annehmen →</a></td></tr></table></td></tr></table></html>';
$message .= '<html><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td><table border="0" cellspacing="0" cellpadding="0"><tr><td><a href="mailto:<?php $email?>?Subject=Reservierung 73&Body=Leider müssen wir Ihre Reservierung ablehnen da wir schon ausgebucht sind" target="_blank" style="font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; background-color: #EB7035; border-top: 12px solid #EB7035; border-bottom: 12px solid #EB7035; border-right: 28px solid #EB7035; border-left: 18px solid #EB7035; display: inline-block;">Ablehnen →</a></td></tr></table></td></tr></table></html>';
$headers = "From: $name\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mail = mail('[email protected]', 'Reservierung', $message, $headers);
if($mail){
echo 'Ihre Reservierung wurde erfolgreich abgeschickt. Sie erhalten in kürze eine Bestätigung';
}
}
?>
*「是否可以將我的mailto收件人設置爲$ email字符串?」 - - 簡短回答:是。 –
*「我的問題是,我不能從表單中的電子郵件到mailto按鈕。」* - 什麼形式?順便說一句,你發送HTML格式,所以你不需要'\ n'的正文。那些會直接顯示'\ n'。 –
當然,但是:'mailto'方案是一個巨大的陷阱,請記住,這需要在客戶端支持該功能,而您不知道該功能是否存在。因此,例如簡單網絡郵件程序的所有用戶都將無法使用這種按鈕! – arkascha