Guest User

Untitled

a guest
Oct 20th, 2017
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #!/usr/bin/php -q
  2. <?php
  3.  
  4. mail( "GlennRowe@GlennRowe.ca", "Boo","Blah", "From: Me@Me.comrn" );
  5. die("DEAD");
  6.  
  7.  
  8. // Specify where emails should be forwarded to and who it should come from
  9. $new_email_recipient="GlennRowe@GlennRowe.ca";
  10. $new_email_sender="Next Level Property Management <ClientCare@NextLevelPM.ca>";
  11.  
  12. // Define the new mail headers
  13. $additional_header="To: ".$new_email_recipient."rn";
  14. $additional_header.="From: ".$new_email_sender."rn";
  15.  
  16.  
  17.  
  18.  
  19. $fd = fopen("php://stdin", "r");
  20. $message = "";
  21. while (!feof($fd))
  22. {
  23. $message .= fread($fd, 1024);
  24. }
  25. fclose($fd);
  26.  
  27. // Split the string into array of strings, each of the string represents a single line received
  28. $lines = explode("n", $message);
  29.  
  30.  
  31. // Initialize variables which will assigned later on
  32. $from = "";
  33. $subject = "";
  34. $headers = "";
  35. $message = "";
  36. $is_header= true;
  37.  
  38. //loop through each line
  39. for ($i=0; $i < count($lines); $i++)
  40. {
  41. if ($is_header)
  42. {
  43. // Add header lines to the headers variable
  44. $headers .= $lines[$i]."rn";
  45.  
  46. // Split out the subject portion
  47. if (preg_match("/^Subject: (.*)/", $lines[$i], $matches))
  48. {
  49. $subject = $matches[1];
  50. }
  51. // Split out the recipient portion
  52. if (preg_match("/^To: (.*)/", $lines[$i], $matches))
  53. {
  54. $to = $matches[1];
  55. }
  56. //Split out the sender information portion
  57. if (preg_match("/^From: (.*)/", $lines[$i], $matches))
  58. {
  59. $from = $matches[1];
  60. }
  61. }
  62. else
  63. {
  64. /// Add message lines to the message variable
  65. $message .= $lines[$i]."rn";
  66. }
  67.  
  68. if (trim($lines[$i])=="")
  69. {
  70. // empty line, header section has ended
  71. $is_header = false;
  72. }
  73. }
  74.  
  75. //Prepend the original sender and original recipient to the beginning of the message
  76. $message="From: ".$from."rn"."To: ".$to."rn"."rn".$message;
  77.  
  78. //For debugging puposes, echo the values to ensure they are correct.
  79. //echo "New Recipient:".$new_email_recipient."nNew Sender:".$new_email_sender."n";
  80. //echo "Subject:".$subject."nFrom:".$from."nMessage:".$message."nHeaders:".$additional_header;
  81.  
  82. //Send a copy of the message to the new recipient
  83. mail( $new_email_recipient, $subject,$message, $additional_header );
  84.  
  85. ?>
  86.  
  87. <?php
  88.  
  89. mail( "Me@MyDomain.com", "Boo","Blah", "From: Someone@Somewhere.comrn" );
  90. die("Mail Sent");
  91.  
  92. ?>
  93.  
  94. <?php
  95. #!/usr/bin/php -q
  96. mail( "Me@MyDomain.com", "Boo","Blah", "From: Someone@Somewhere.comrn" );
  97.  
  98. ?>
Add Comment
Please, Sign In to add comment