Jump to content

jakebur01

Members
  • Posts

    885
  • Joined

  • Last visited

Everything posted by jakebur01

  1. Is there a reliable way to have php process e-mails for a gmail account. I need it to look at all the new e-mails that have VSI-FAX in the subject and run the code below to swipe out the failed fax number. These are fax failure e-mails. $pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i'; preg_match($pattern, $email_body, $matches); $fax_number = trim($matches[0]);
  2. I opened it notepad and this is what I have: <?php $Popmonger = new Popmonger();$body = $Popmonger->BodyText();$pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i';preg_match($pattern, $bodytext, $matches);$faxnumber = trim($matches[0]);$body = $Popmonger->BodyText();$pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i';preg_match($pattern, $bodytext, $matches);$faxnumber = trim($matches[0]);$myFile = "vsifax_failures.txt";$fh = fopen($myFile, 'a') or die("can't open file");$stringData = "$faxnumber\n";fwrite($fh, $stringData);fclose($fh);?> But, if I only put tags in there, I get the same error. I have tried posting to the support group from the company, but I have yet to receive a response. http://support.mach5.com/showthread.php?tid=139
  3. Could it be the file type or the type of encoding used?
  4. I changed my code to this: <?$Popmonger = new Popmonger();$body = $Popmonger->BodyText();$pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i';preg_match($pattern, $bodytext, $matches);$faxnumber = trim($matches[0]);$body = $Popmonger->BodyText();$pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i';preg_match($pattern, $bodytext, $matches);$faxnumber = trim($matches[0]);$myFile = "vsifax_failures.txt";$fh = fopen($myFile, 'a') or die("can't open file");$stringData = "$faxnumber\n";fwrite($fh, $stringData);fclose($fh);?> I am still getting: Name cannot begin with the '' character, hexadecimal value 0x20. Line 1. Position 12. The error is always Line 1. Position 12. no matter what I put in the file.
  5. Any idea what would cause this error? It doesn't matter what code I have or whether I use <? ?> or <?PHP ?>. It always throws this error in a third party program I have called PopMonger that will allow you to run a php script to handle a returned e-mail. Name cannot begin with the '' character, hexadecimal value 0x20. Line 1.
  6. COOL! THANKS A BUNCH.
  7. Now I'm getting this: Notice: Undefined variable: failedAddress in C:\Inetpub\wwwroot\smithsadvantage\popmonger\PopmongerClass.php on line 100 Fatal error: Cannot access empty property in C:\Inetpub\wwwroot\smithsadvantage\popmonger\PopmongerClass.php on line 100
  8. I have this class that was built for testing, but I am unable to get it to work for me. PopmongerClass.php <?php //coded for PHP 5 /** * This class will define an object very similar to the Popmonger object returned by PopMonger 3 itself. This class * can be used for debugging purposes by modifying the fields near the top of the class. To use this class, * either paste the following code into your script, or download the <a href="PopmongerClass.zip" alt="PopmongerClass zipfile">PopmongerClass.php file</a>, * unzip it into the same directory as your Popmonger 3 script, and add the text require('PopmongerClass.php'); * to the top of your current PHP script. If you are not running the script via apache or another web server, you may run * the script with the php.exe Command-Line interpreter. </p> */ class Popmonger { public $fields, $headers, $headerText, $bodyText, $messageText, $failedAddress, $mimeParts; public function __construct() { /** * Fields that would be returned by Popmonger 3 if the "Parse feedback using delimiters" box is checked in * the Actions tab of the Task options. */ $this->fields = array( "Robert" , "Smith" , "[email protected]" , "Oct" , "22" , "2006" ); /** * Headers that Popmonger 3 would return for this email. Note that this is an associative array, as is the * array returned by Popmonger 3. */ $this->headers = array( "subject" => "subject" , "from" => "from" , "to" => "to" ); /** * The raw header text for this email. */ $this->headerText = "Subject: ".$this->headers['subject']."\r\nFrom: ".$this->headers['from']."\r\nTo: ".$this->headers['to']; /** * The raw body text for this email. */ $this->bodyText = "This is the body which includes both HTML and TEXT portions if both were sent."; /** * The raw message text for this email. */ $this->messageText = "This is the raw message text which includes the ENTIRE MESSAGE, headers and all."; /** * The original sender address for created a bounced/failure address list. */ $this->failedAddress = "[email protected]"; /** * The MIME parts of this email, which would normally include any files attached. Feel free to use readfile() * here if you actually need to return a file for debugging purposes. */ $this->mimeParts = array( "file 1" , "file 2" , "file 3" ); } /** * This function will return the number of fields that have been successfully parsed by Popmonger 3 (in * this case, a count of the number of fields in the fields var array. * * @return - integer Number of fields parsed out of this email */ function FieldsCount() { return count( $this->fields ); } /** * This function will return the number of MIME parts in this email (in this case, a count of the number of * fields in the mimeParts var array. * * @return - integer Number of MIME parts in this email */ function MIMEPartsCount() { return count( $this->$mimeParts ); } /** * This function will return the message text associated with this email. * * @return - String message text */ function MessageText() { return $this->$messageText; } /** * This function will return the failed sender address associated with a bounced email. * * @return - String message text */ function FailedAddress() { return $this->$failedAddress; } /** * This function will return the header text associated with this email. * * @return - String header text */ function HeaderText() { return $this->$headerText; } /** * This function will return the body text associated with this email. * * @return - String body text */ function BodyText() { return $this->$bodyText; } /** * This function will return the i-th field associated with the email, based on the text that Popmonger 3 * parsed out. Note that this function does not perform any bounds-checking! Use the FieldsCount() function to * ensure that the index is within bounds. * * @param int - Field index to retrieve * * @return - String field value */ function Field( $i ) { return $this->fields[$i]; } /** * Send an email to this recipient. Note that this function does NOT actually send an email! It is only here * for debugging purposes. * * @param String - From: email address * @param String - To: email address * @param String - Subject of the email * @param String - Body of the email * @param String - Headers for this email */ function SendMail( $from , $to , $subject , $body , $headers ) { echo "Would have sent email to ".$to." from ".$from." with subject ".$subject."\r\n"; } /** * Redirect this message to another email address. Note that this function does NOT send email, it is only * here for debugging purposes. * * @param String - Email address to redirect this message to */ function RedirectMessage( $email ) { echo "redirecting this message to ".$email."r\n"; } /** * Reply to this message with this text. Note that thie function does NOT send email, it is only here for * debugging purposes. * * @param String - From: email address * @param String - Subject of the email * @param String - Text to reply with */ function ReplyWithText( $from , $subject , $replyText ) { echo "replying to ".$from." with subject ".$subject." and text ".$replyText."\r\n"; } /** * Save text to a file. * * @param String - Filename to write to * @param String - Text to write to this file * @param boolean - TRUE to append to a file, FALSE to truncate the file to 0 length and then write */ function SaveToFile( $filename , $text , $append ) { $write = 'w'; if( $append == TRUE || $append == '1' ) { $write = 'a'; } $fp = fopen( $filename , $write ); fputs( $fp , $text ); fclose( $fp ); } /** * Returns this header field. This would usually refer to the header fields parsed out by PopMonger, but * for debugging purposes returns the value of this element in the headers var array. * * @param String - Name of the header field to retrieve * * @return String - Value of this header field */ function HeaderField( $name ) { return $this->headers[$name]; } /** * Returns this MIME part of the email. This would usually refer to the MIME parts of the email, but for * debugging purposes returns the value of the mimeParts var array. * * @param integer - Index of the element to retrieve * * @return String - Value of this MIME part of the email */ function MIMEPart( $index ) { return $this->mimeParts[$index]; } } // End of Popmonger Class declaration //Instantiate a new popmonger object with the same name as the object returned by PopMonger itself. //$popmonger = new Popmonger(); //Confirmation that a PopMonger object was created. //echo "Made a new popmonger!"; ?> popmonger.php ( page for testing ) <?php include ('PopmongerClass.php'); echo $Popmonger->FailedAddress(); echo $Popmonger->MessageText(); ?> Here is the error I am getting: Notice: Undefined variable: Popmonger in C:\Inetpub\wwwroot\smithsadvantage\popmonger\popmonger.php on line 4 Fatal error: Call to a member function FailedAddress() on a non-object in C:\Inetpub\wwwroot\smithsadvantage\popmonger\popmonger.php on line 4
  9. This is what I am really looking to do. Retrieve the fax number from the e-mail and write it to a text file. I am just not sure about the class and how it should be formatted. <?php class object Popmonger string HeaderText; string BodyText; string MessageText; string FailedAddress; string HeaderField($sHeader_name); string Field($iFieldNumber); int FieldsCount; string MIMEPart($iPartNumber); int MIMEPartsCount; void RedirectMessage("sTo_address1,To_address2,To_address3"); void ReplyWithText($fsFom_address, $sSubject, $sReply_text); void SendMail($from_address,$sTo_address,$sSubject_text,$sBody_text,$sEx_headers); void SaveToFile($sFile_name, $sText_to_save, $bIsAppend); $pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i'; preg_match($pattern, $bodytext, $matches); $faxnumber = trim($matches[0]); $myFile = "vsifax_failures.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = "$faxnumber\n"; fwrite($fh, $stringData); fclose($fh); ?>
  10. I am following this code here http://www.mach5.com/products/popmonger/manual30/scripts.html to retrieve sections of the returned e-mail. However, this class does not look right. class object Popmonger string HeaderText; string BodyText; string MessageText; string FailedAddress; string HeaderField($sHeader_name); string Field($iFieldNumber); int FieldsCount; string MIMEPart($iPartNumber); int MIMEPartsCount; void RedirectMessage("sTo_address1,To_address2,To_address3"); void ReplyWithText($fsFom_address, $sSubject, $sReply_text); void SendMail($from_address,$sTo_address,$sSubject_text,$sBody_text,$sEx_headers); void SaveToFile($sFile_name, $sText_to_save, $bIsAppend); I want to retrieve the string BodyText; or string MessageText; and run something like this: $pattern = '~fax\s+#\s+:\s+\K(??!from).)+~i'; preg_match($pattern, $bodytext, $matches); $fax = trim($matches[0]);
  11. Thank you crayonviolent. This is exactly what I had in mind. Thank you cssfreakie. Jake
  12. "How can I extract the fax # out of this e-mail message? I will either be using a 3rd party program that handles returned messages or build a little mail reading script that will handle this. I want to extract the fax number located between "To fax # :" and "From fax # :". Here is a copy of the e-mail I will receive when the fax failed: Status for VSI-FAX fax job: 1025 Submitted by: vsifax E-mail : [email protected] Submit time : 06/24 11:15 Queue : fax1 Result : expired Status : Max tries reached To name : <none> From name : VSIFAX Administrator To company : <none> From company: <none> To fax # : 555-555-3551 From fax # : <none> To voice # : <none> From voice #: <none> Subject : <none> Num dialed : 15048323291 usrtag1 : 001210 Cover : 1 pg default File 1 : 2 pgs /u/ssc/ssi7/docdel/001210.vsi Total pgs : 3 pgs Attempt Send-Time Result CSI ------- ----------- ------------------ ---------------- 1 06/24 11:16 Timed out <none> 2 06/24 11:22 No carrier <none> 3 06/24 11:29 Timed out <none> 4 06/24 11:36 Timed out <none> 5 06/24 11:42 Timed out <none>
  13. I really need to keep the dashes and replace forward slashes and periods with dashes. Jake
  14. What about converting the periods and forward slashes to dashes? Would I do something like this? $fax=str_replace('/','-',$fax); $fax=str_replace('.','-',$fax); $fax = preg_replace("/[^0-9]/","", $fax)
  15. Hello, I have database of fax number and I need to copy these numbers to a separate table on a daily basis. The format the customer service employees have been using are: (555)555-5555, 555/555-5555, 555.555.5555, 555/555-5555 FAX, (fax)555/555-5555, etc. I would like to correct and strip the fax number before having them transferred into the database that the actually fax server will be using. Jake $fax=odbc_result($rs,"PHONE_2"); $fax = strtolower($fax); $fax=str_replace('/','-',$fax); $fax=str_replace('.','-',$fax); $find=array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "%", "!", "@", "#", "$", "^", "&", "*","~", "+", ":", "=", "?", "'", "<", '\\', '(', ')', '[', ']', '{', '}'); str_replace($find, '', $fax); $fax=trim($fax);
  16. This may be the longer way around than using Count in the query, but doing something like this always works for me. $result = mysql_query("SELECT * FROM iptablename WHERE ip = '{$_SERVER['REMOTE_ADDR']}'", $link); $num_rows = mysql_num_rows($result); if($num_rows>"0") { // do not let them sign up } else { // display signup code }
  17. How do you use a double quote in str_replace? $queryline = str_replace(""","'""",$line);
  18. It would not return data, but it would keep my script from hanging up.
  19. Cool! What about if it contained a double quote? How would you escape that?
  20. As an alternative, could I do something like this so it will skip the query all together? Like: if($line contains ' OR $line contains " OR $line contains ,) { //do nothing } else { ... process query }
  21. Mmmnn. There's gotta be a way to do this.
  22. But, this is an odbc query? Can I still generate a MySQL connection, store mysql_real_escape_string() into a variable, and then use that value with my odbc query?
  23. I am doing an odbc query. And one of the e-mails has a ' in it. Example: woody'[email protected] Warning: odbc_exec() [function.odbc-exec]: SQL error: [ProvideX][ODBC Driver]Unexpected extra token: woody'[email protected], SQL state 37000 in SQLExecDirect in C:\Inetpub\wwwroot\smithsadvantage\failed_messages.php on line 40 Error in SQL However, I still want to be able to select info from the database based on the email address above. How can I still query the data using a value that has quotes and other weird characters? if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT CUSTOMER_NUM, CUSTOMER_NAME, PHONE_1 FROM AR_CUST_MAST WHERE EMAIL_1 = '$line'"; //print $sql; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} while (odbc_fetch_row($rs)) { $acct=odbc_result($rs,"CUSTOMER_NUM"); $name=odbc_result($rs,"CUSTOMER_NAME"); $phone=odbc_result($rs,"PHONE_1"); }
  24. Cool. Thanks. Here is the full code: <?php set_time_limit(900); ini_set('max_execution_time', '999'); include_once('inc/data.inc'); $file = file_get_contents('failed_messages/failed_messages.txt'); $lines = explode("\n",$file); // now you have an array with all the lines in it. You can loop through it and do whatever you want. foreach($lines as $line){ $line=trim($line); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT CUSTOMER_NUM, CUSTOMER_NAME, PHONE_1 FROM AR_CUST_MAST WHERE EMAIL_1 = '$line'"; //print $sql; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} while (odbc_fetch_row($rs)) { $acct=odbc_result($rs,"CUSTOMER_NUM"); $name=odbc_result($rs,"CUSTOMER_NAME"); $phone=odbc_result($rs,"PHONE_1"); } $acct =mysql_real_escape_string($acct); $name =mysql_real_escape_string($name); $phone =mysql_real_escape_string($phone); $query = "insert into failed_messages values ('0','$acct', '$name', '$phone', '$line')"; mysql_query($query, $db); } //$myFile = "failed_messages/failed_messages.txt"; //$fh = fopen($myFile, 'w'); //fclose($fh); // erase file: file_put_contents('failed_messages/failed_messages.txt',''); ?>
  25. What about something like this? $myFile = "failed_messages/failed_messages.txt"; $fh = fopen($myFile, 'w'); fclose($fh);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.