Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php -q
- <?php
- mail( "GlennRowe@GlennRowe.ca", "Boo","Blah", "From: Me@Me.comrn" );
- die("DEAD");
- // Specify where emails should be forwarded to and who it should come from
- $new_email_recipient="GlennRowe@GlennRowe.ca";
- $new_email_sender="Next Level Property Management <ClientCare@NextLevelPM.ca>";
- // Define the new mail headers
- $additional_header="To: ".$new_email_recipient."rn";
- $additional_header.="From: ".$new_email_sender."rn";
- $fd = fopen("php://stdin", "r");
- $message = "";
- while (!feof($fd))
- {
- $message .= fread($fd, 1024);
- }
- fclose($fd);
- // Split the string into array of strings, each of the string represents a single line received
- $lines = explode("n", $message);
- // Initialize variables which will assigned later on
- $from = "";
- $subject = "";
- $headers = "";
- $message = "";
- $is_header= true;
- //loop through each line
- for ($i=0; $i < count($lines); $i++)
- {
- if ($is_header)
- {
- // Add header lines to the headers variable
- $headers .= $lines[$i]."rn";
- // Split out the subject portion
- if (preg_match("/^Subject: (.*)/", $lines[$i], $matches))
- {
- $subject = $matches[1];
- }
- // Split out the recipient portion
- if (preg_match("/^To: (.*)/", $lines[$i], $matches))
- {
- $to = $matches[1];
- }
- //Split out the sender information portion
- if (preg_match("/^From: (.*)/", $lines[$i], $matches))
- {
- $from = $matches[1];
- }
- }
- else
- {
- /// Add message lines to the message variable
- $message .= $lines[$i]."rn";
- }
- if (trim($lines[$i])=="")
- {
- // empty line, header section has ended
- $is_header = false;
- }
- }
- //Prepend the original sender and original recipient to the beginning of the message
- $message="From: ".$from."rn"."To: ".$to."rn"."rn".$message;
- //For debugging puposes, echo the values to ensure they are correct.
- //echo "New Recipient:".$new_email_recipient."nNew Sender:".$new_email_sender."n";
- //echo "Subject:".$subject."nFrom:".$from."nMessage:".$message."nHeaders:".$additional_header;
- //Send a copy of the message to the new recipient
- mail( $new_email_recipient, $subject,$message, $additional_header );
- ?>
- <?php
- mail( "Me@MyDomain.com", "Boo","Blah", "From: Someone@Somewhere.comrn" );
- die("Mail Sent");
- ?>
- <?php
- #!/usr/bin/php -q
- mail( "Me@MyDomain.com", "Boo","Blah", "From: Someone@Somewhere.comrn" );
- ?>
Add Comment
Please, Sign In to add comment