Index: cleanup/mms_us_metropcs/README.txt =================================================================== RCS file: cleanup/mms_us_metropcs/README.txt diff -N cleanup/README.txt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cleanup/README.txt 3 Mar 2009 00:25:18 -0000 @@ -0,0 +1,24 @@ +; $Id$ + +mms_us_metropcs +--------------- +This is a prototype module to try and clean up messages that are posted via +the MMS feature of a mobile phone. The emails generated this way typically +contain additional logos from the service provider, and possible additional +text. + +hook_mailsave_clean is triggered by mailsave before it calls hook_mailsave. +You can therefore intercept the node and the email attachments before +other modules begin processing. + +By implementing hook_mailsave_clean in a module you can therefore discard +additional images that are attached and modify the text of the node. + +hook_mailsave_clean passes the node, but also information about the mailbox +and the email that is currently in use. + +-------- + +MetroPCS messages are identified by being from @mymetropcs.com. The +messages are plain text, but have a long string attached to the end +which is stripped. There are no additional attachments to remove. Index: cleanup/mms_us_metropcs.inc =================================================================== RCS file: cleanup/mms_us_metropcs.inc diff -N cleanup/mms_us_metropcs.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ cleanup/mms_us_metropcs.inc 3 Mar 2009 00:25:18 -0000 @@ -0,0 +1,74 @@ +fromaddress)) { + + // Build a regex to extract message body + // This regex identifies the actual message text in the email + $end_pattern = preg_quote('This message was sent using picture-talk messaging service from MetroPCS.'); + $pattern = '@^(.*)' . $end_pattern . '@Us'; + + // Check for regex success in case the provider changes their format + // Worst case is that match fails and nothing is changed + if (preg_match($pattern, $node->body)) { + + // Find the HTML element containing user-supplied text. + preg_match_all('!