douyan2680 2017-05-08 15:01
浏览 61
已采纳

我可以将mailto的收件人设置为php字符串吗?

is it possible to set my mailto recipient to the $email string? I have a reservation form on my website and i want to have 2 buttons(Accept/Decline) in the mail that i get from it. The buttons should automatically open a new email windows with the set body and the recipient email from the form. My problem is that i cant get the email from the form into the mailto button.

some help would be nice :)

 <?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."
<br />"."Personen: ".$amount."
<br />"."Datum: ".$date."
<br />"."Uhrzeit: ".$time."
<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 &rarr;</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 &rarr;</a></td></tr></table></td></tr></table></html>';

$headers = "From: $name
";
$headers .= "Reply-To: $email
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";

    $mail = mail('tes@test.test', 'Reservierung', $message, $headers);

    if($mail){
        echo 'Ihre Reservierung wurde erfolgreich abgeschickt. Sie erhalten in kürze eine Bestätigung';
    }

}
?>
  • 写回答

1条回答 默认 最新

  • dtzhfb4869 2017-05-08 15:06
    关注

    You do not have to open php tags again. Just add slashes and concatenate your variable.

    $message .= '<html>...<a href="mailto:' . $email . '?...</html>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度