In phpScheduleIt I have a form that generates invoices based on input by a user. I have a PHP script that I embedded in the output function that grabs a copy of that output and sends it in the background right before the output is displayed on the screen to print.
I want to be able CC an additional e-mail address but the trick is I want it to grab an e-mail address already entered in the invoice before it is submitted and send an additional copy to that address. Here is the code I'm using that works great so far.
<?php
$to = 'hiddenaddress@mywebsite.com';
$subject = 'Here's Your Receipt';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: hiddenaddress@mywebsite.com\r\nReply-To: DO NOT REPLY";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<html>
what's being sent
</html>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
//echo $mail_sent ? "Mail sent" : "Mail failed";
?>The way the form posts it uses <?php print "$client_email"; ?> to output on the page and the copy that's sent. However, I want the e-mail that's entered to not only send to the hidden address but also to <?php print "$client_email"; ?>. Here's what I have and it's not working.
<?php
$to = '<?php print "$client_email"; ?>';
$bcc = 'hiddenaddress@mywebsite.com';
$subject = 'Here's Your Receipt';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: hiddenaddress@mywebsite.com\r\nReply-To: DO NOT REPLY";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $bcc, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
//echo $mail_sent ? "Mail sent" : "Mail failed";
?>Basically I'm trying to get two copies of the HTML page to go out. One to the client and one to me so I can have a copy as well. ANY IDEAS?
Thanks,
ItalianStalian