0

我有一个简单的表格。基本上尝试通过电子邮件复制共享认为这已经足够了。我想将这封电子邮件的副本发送到 $email 变量(是的,可能不需要带斜杠),有什么想法吗?通过谷歌看到一堆帖子,但无法弄清楚;

<?php
        $EmailFrom = "admin@test.com";
        $EmailTo  = "admin@test.com";
        $Subject = "Check out this video.";
        $email = !empty($_POST['email']) ? Trim(stripslashes($_POST['email'])) : false; 

        $Body = "Take a look at this; youtubelink...";

        $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
        header('Location: /#');
?>
4

2 回答 2

1

只需添加另一个 mail(); 功能

<?php
        $EmailFrom = "admin@test.com";
        $EmailTo  = "admin@test.com";
        $Subject = "Check out this video.";
        $email = !empty($_POST['email']) ? Trim(stripslashes($_POST['email'])) : false; 

        $BodyReceiver = "Take a look at this; youtubelink...";
        $BodySender = "You sent the following message " . $BodyReceiver . " to " . $EmailTo . ".";

        $successReceiver = mail($EmailTo, $Subject, $BodyReceiver, "From: <$EmailFrom>");
        $successSender = mail($EmailFrom, $Subject, $BodySender, "From: <no-reply@text.com");
        header('Location: /#');
?>

或类似的东西...

正如 bozdoz 建议的那样,您可能会使用密件抄送,但它将是原件的完整副本。您将无法更改发件人电子邮件或按摩(例如“您将以下按摩...发送到...”等等。

于 2012-12-03T00:49:20.917 回答
1

只需像这样编辑您的脚本,副本将仅在原件将发送:

<?php
    $EmailFrom = "admin@test.com";
    $EmailTo  = "admin@test.com";
    $Subject = "Check out this video.";
    $email = !empty($_POST['email']) ? Trim(stripslashes($_POST['email'])) : false; 

    $Body = "Take a look at this; youtubelink...";

    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

    if ($success)
        mail($EmailFrom, $Subject, $Body, "From: <$EmailFrom>");

    header('Location: /#');
?>
于 2012-12-03T00:50:39.997 回答