我有一个注册表格,允许用户注册并成为我网站上的会员。到目前为止,一旦他们注册了他们的详细信息,就会在数据库中发送,并且他们会收到一封电子邮件,表示感谢发送2个不同的电子邮件给2个不同的收件人?
我想复制脚本,以便我可以发送不同的电子邮件,让我知道用户何时注册并将其发送到我的电子邮件。
我试图这样做,因为发送给用户的电子邮件包含一个随机生成的md5哈希代码,我还需要发送给我的邮件发送给我,告诉我他们已经注册。
我设法让两封电子邮件发送到正确的电子邮件帐户。然而,发送给我的电子邮件让我知道用户已经注册,也正在发送给用户,我不想让他们去看他们?
任何人都可以建议我要去哪里错了吗?由于
代码来发送电子邮件给用户:
<?php
/**
* ShuttleCMS - A basic CMS coded in PHP.
* code generator - Used for allowing a user to generate a code
*
* @author Dan <[email protected]>
* @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 <[email protected]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 <[email protected]>
* @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 protected]\r\n";
$headersconfirm .= "From: siteindex.com <[email protected]>\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);
?>
很多代码。只需通过他们的电子邮件发送给用户。然后发送给你自己,与您的电子邮件 – Ibu
谢谢你能够解释一下你的意思,就像一个例子,如果可能的话谢谢。 –
你可以只为自己打电话,以便只需发送一封电子邮件? – David