Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向两个不同的收件人发送两封不同的电子邮件?_Php_Email - Fatal编程技术网

Php 向两个不同的收件人发送两封不同的电子邮件?

Php 向两个不同的收件人发送两封不同的电子邮件?,php,email,Php,Email,我有一个注册表格,允许用户注册并成为我网站的会员。到目前为止,一旦他们注册了自己的详细信息,这些信息就会进入数据库,他们会收到一封电子邮件,表示感谢 我正在尝试复制脚本,以便我可以发送不同的电子邮件,让我知道用户何时注册并将其发送到我的电子邮件 我正试图这样做,因为发送给用户的电子邮件包含随机生成的md5哈希代码,我也需要在发送给我的电子邮件中发送给我,告诉我他们已注册 我已设法将这两封电子邮件发送到正确的电子邮件帐户。然而,发送给我让我知道某个用户已注册的电子邮件也发送给该用户,我不想发送给他

我有一个注册表格,允许用户注册并成为我网站的会员。到目前为止,一旦他们注册了自己的详细信息,这些信息就会进入数据库,他们会收到一封电子邮件,表示感谢

我正在尝试复制脚本,以便我可以发送不同的电子邮件,让我知道用户何时注册并将其发送到我的电子邮件

我正试图这样做,因为发送给用户的电子邮件包含随机生成的md5哈希代码,我也需要在发送给我的电子邮件中发送给我,告诉我他们已注册

我已设法将这两封电子邮件发送到正确的电子邮件帐户。然而,发送给我让我知道某个用户已注册的电子邮件也发送给该用户,我不想发送给他们

有人能告诉我哪里出了问题吗?谢谢

向用户发送电子邮件的代码:

<?php

/**
 * ShuttleCMS - A basic CMS coded in PHP.
 * code generator - Used for allowing a user to generate a code
 * 
 * @author Dan <dan@danbriant.com>
 * @version 0.0.1
 * @package ShuttleCMS
 */
define('IN_SCRIPT', true);
// Start a session
session_start();

/*
 * Generates new code and puts it on database
 */

//Generate a RANDOM MD5 Hash for a code
$random_code=md5(uniqid(rand()));

//Take the first 8 digits and use them as the password we intend to email the user
$emailcode=substr($random_code, 0, 8);

//Encrypt $emailpassword in MD5 format for the database
$registrationcode=($emailcode);

// Make a safe query
$query = sprintf("UPDATE `ptb_registrations` SET `registration_code` = '%s' WHERE email = \"$email\"",
                    mysql_real_escape_string($registrationcode));

mysql_query($query)or die('Could not update members: ' . mysql_error());

?>

<?php

 $subjectconfirm = " Thanks for your Registration";
 $headersconfirm = "To: $email\r\n"; 
 $headersconfirm .= "From: siteindex.com <registrations@siteindex>\r\n";                                                                                                                                                                                                            
 $headersconfirm .= "Content-type: text/html\r\n"; 

  $sep = sha1(date('r', time()));
 $bodyconfirm = <<< EOF

(EMAIL BODY)

EOF;


 // Finally, send the email
 mail($email, $subjectconfirm, $bodyconfirm, $headersconfirm);

?>

然后我复制了这样的代码,但替换了收件人的电子邮件地址。它可以发送到我的电子邮件帐户,但它会将两封电子邮件都发送给用户,我不希望他们收到为我准备的电子邮件

向我发送电子邮件的代码:

<?php

    /**
     * ShuttleCMS - A basic CMS coded in PHP.
     * code generator - Used for allowing a user to generate a code
     * 
     * @author Dan <dan@danbriant.com>
     * @version 0.0.1
     * @package ShuttleCMS
     */
    define('IN_SCRIPT', true);
    // Start a session
    session_start();

    /*
     * Generates new code and puts it on database
     */

    //Generate a RANDOM MD5 Hash for a code
    $random_code=md5(uniqid(rand()));

    //Take the first 8 digits and use them as the password we intend to email the user
    $emailcode=substr($random_code, 0, 8);

    //Encrypt $emailpassword in MD5 format for the database
    $registrationcode=($emailcode);

    // Make a safe query
    $query = sprintf("UPDATE `ptb_registrations` SET `registration_code` = '%s' WHERE email = \"$email\"",
                        mysql_real_escape_string($registrationcode));

    mysql_query($query)or die('Could not update members: ' . mysql_error());

    ?>

    <?php

     $subjectconfirm = " Thanks for your Registration";
     $headersconfirm = "To: signups@siteindex.com\r\n"; 
     $headersconfirm .= "From: siteindex.com <signups@siteindex>\r\n";                                                                                                                                                                                                          
     $headersconfirm .= "Content-type: text/html\r\n"; 

      $sep = sha1(date('r', time()));
     $bodyconfirm = <<< EOF

    (DIFFERENT EMAIL BODY)

    EOF;


     // Finally, send the email
     mail($email, $subjectconfirm, $bodyconfirm, $headersconfirm);

    ?>

您将从中注意到,第一个参数是电子邮件发送到的位置。你没有改变它。您只更改了标题。要向其他人发送电子邮件,请更改:

mail($email, $subjectconfirm, $bodyconfirm, $headersconfirm);
致:

当然,用密件抄送给自己比复制所有这些代码要明智得多。

您会从中注意到,第一个参数是电子邮件发送到的位置。你没有改变它。您只更改了标题。要向其他人发送电子邮件,请更改:

mail($email, $subjectconfirm, $bodyconfirm, $headersconfirm);
致:


当然,将代码以密件传给自己比复制所有这些代码要明智得多。

我认为没有必要复制代码。只需发送两封电子邮件:

$emails = 'youremail@email.com, theiremail@email.com';
mail($emails, $subjectconfirm, $bodyconfirm, $headersconfirm);
或密件抄送:

$headersconfirm .= 'Bcc: youremail@email.com' . "\r\n";

看看。

我看不出有必要复制代码。只需发送两封电子邮件:

$emails = 'youremail@email.com, theiremail@email.com';
mail($emails, $subjectconfirm, $bodyconfirm, $headersconfirm);
或密件抄送:

$headersconfirm .= 'Bcc: youremail@email.com' . "\r\n";

看看。

有很多代码。只需将其与用户的电子邮件一起发送给用户即可。然后将它发送给你自己,连同你的电子邮件谢谢你能解释一下你的意思吗,如果可能的话,举个例子谢谢。你能自己用密件抄送,这样你只需要发送一封电子邮件吗?很多代码。只需将其与用户的电子邮件一起发送给用户即可。然后将它发送给你自己,连同你的电子邮件谢谢你能解释一下你的意思吗,如有可能,举个例子谢谢。你能自己用密件抄送吗,这样你只需要发送一封电子邮件?包括
youremail@email.com
作为密件抄送收件人可能比收件人更可取,但在其他方面你是正确的。。。这里不需要复制任何代码。包括
youremail@email.com
作为密件抄送收件人可能比收件人更可取,但在其他方面你是正确的。。。这里不需要复制任何代码。