Guest User

Untitled

a guest
Nov 23rd, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. use warnings;
  2. use strict;
  3.  
  4. use Mail::POP3Client;
  5. use MIME::Base64;
  6.  
  7. my $hostname = "xxxxxx";
  8. my $username = "xxxxx;
  9. my $password = "xxxxx";
  10.  
  11. my $conn = new Mail::POP3Client( USER => $username, PASSWORD => $password, HOST => $hostname );
  12.  
  13. my $email_number = $conn -> Count() - 11; #get the latest email # from Count();
  14.  
  15. print "\n\n<!DOCTYPE html>\n";
  16. print "<html>\n";
  17. print "<body>\n";
  18. print "<p>\n";
  19.  
  20. foreach( $conn->Head( $email_number ) ) {
  21. /^(From|Subject):\s+/i && print $_, "\n";
  22. }
  23.  
  24. print "</p>\n\n";
  25.  
  26. my $ciphertext = $conn->Body( $email_number );
  27.  
  28. #clean the ciphertext
  29. $ciphertext =~ s/Content-Type:\stext\/plain;//g;
  30. $ciphertext =~ s/charset="utf-8"//g;
  31. $ciphertext =~ s/Content-Transfer-Encoding:\sbase64//g;
  32. $ciphertext =~ s/Content-Type:\stext\/html;//g;
  33. $ciphertext =~ s/--_000_41DADE848657754488503BD616F1ADE607250A88_--//g;
  34. $ciphertext =~ s/--_000_41DADE848657754488503BD616F1ADE607317EE6_//g;
  35. $ciphertext =~ s/--_000_41DADE848657754488503BD616F1ADE6073C5F3B//g;
  36.  
  37. my $plaintext = decode_base64( $ciphertext );
  38. #print "Body: " . $plaintext;
  39.  
  40. my @plain = split(/\n/,$plaintext);
  41.  
  42. #@plain = grep { defined() and length() } @plain; # this eliminates the blank elements in the array, but its not a good idea if one of the column is blank
  43. =pod
  44. foreach(@plain){
  45. if( ( defined $_) and !($_ =~ /^$/ )){
  46. push(@plain, $_);
  47. }
  48. }
  49. =cut
  50.  
  51. my $plain = @plain;
  52.  
  53. print "arraysize: " . $plain;
  54.  
  55. my $note_num = 1;
  56.  
  57. my $i = 38;
  58. my $j = 0;
  59. my $x = 0;
  60.  
  61. while (!($plain[$i] =~ /Grand/)){
  62. print "\n\n<br><h3>NOTE # $note_num</h3>\n";
  63. $note_num++;
  64.  
  65. print "<p>Case Owner: " . $plain[$i] . "</p>\n";
  66. $i = $i + 2;
  67. print "<p>Created By: " . $plain[$i] . "</p>\n";
  68. $i = $i + 2;
  69. print "<p>GoToAssist ID: " . $plain[$i] . "</p>\n";
  70. $i = $i + 2;
  71.  
  72. $x = $i;
  73. $j = $i+2;
  74. # $plain[$x] = "";
  75. #scan the elements until you find 'Email' or 'Phone' or 'GoToAssist'
  76. while(!($plain[$j] =~ /[Email|Phone|GoToAssist]/)){
  77. # if(defined $plain[$j]){
  78. $plain[$x] = $plain[$x] . "&nbsp;" . $plain[$j];
  79. $j++;
  80. # }
  81. }
  82.  
  83. print "<p>Description: " . $plain[$x] . "</p>\n";
  84. $i = $j;
  85.  
  86. print "<p>Case Origin: " . $plain[$i] . "</p>\n";
  87. $i = $i + 2;
  88.  
  89. $x = $i;
  90. $j = $i+2;
  91. # $plain[$x] = "";
  92.  
  93. while(!($plain[$j] =~ /\d\.\d/)){ #scan the lines until you find "digit.digit"
  94. # if(defined $plain[$j]){
  95. $plain[$x] .= " " . $plain[$j];
  96. $j++;
  97. # }
  98. }
  99.  
  100. print "<p>Resolution Summary: " . $plain[$x] . "</p>\n";
  101. $i = $j;
  102.  
  103. #print "<p>Case Comments: " . $plain[$i] . "</p>\n";
  104. #$i = $i + 2;
  105.  
  106. print "<p>Version Reported: " . $plain[$i] . "</p>\n";
  107. $i = $i + 2;
  108. print "<p>Product Feature: " . $plain[$i] . "</p>\n";
  109. $i = $i + 2;
  110. print "<p>Product: " . $plain[$i] . "</p>\n";
  111. $i = $i + 2;
  112. print "<p>Contact Name: " . $plain[$i] . "</p>\n";
  113. $i = $i + 2;
  114. print "<p>Affected Owner: " . $plain[$i] . "</p>\n";
  115. $i = $i + 2;
  116. print "<p>Case ID: " . $plain[$i] . "</p>\n";
  117. $i = $i + 2;
  118. print "<p>Case Number: " . $plain[$i] . "</p>\n";
  119. $i = $i + 2;
  120. print "<p>Account Name: " . $plain[$i] . "</p>\n";
  121. $i = $i + 2;
  122. print "<p>Subject: " . $plain[$i] . "</p>\n";
  123. $i = $i + 2;
  124. print "<p>Date/Time Opened: " . $plain[$i] . "</p>\n";
  125. $i = $i + 2;
  126. print "<p>Closed: " . $plain[$i] . "</p>\n";
  127. $i = $i + 2;
  128. }
  129.  
  130. print "</body>\n";
  131. print "</html>";
  132.  
  133. =pod
  134. for(my $i = 0; $i < $plain; $i++){
  135. print "\n" . $i . " <> " . $plain[$i];
  136. }
  137. =cut
  138.  
  139. $conn->close();
Add Comment
Please, Sign In to add comment