src/Spamcop.php
public function parseSpamReportCustom()
    {

        $reports = [ ];
        $body = $this->parsedMail->getMessageBody();

        // Grab the message part from the body
        preg_match(
            '/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s',
            $body,
            $matches
        );
        if (!empty($matches['message'])) {
            $report['message'] = $matches['message'];
        }

        // Grab the Evidence from the body
        preg_match(
            '/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s',
            $body,
            $matches
        );

        if (!empty($matches['evidence'])) {
            $parsedEvidence = new MimeParser();
            $parsedEvidence->setText($matches['evidence']);
            $report['evidence'] = $parsedEvidence->getHeaders();
        }

        // Now parse the data from both extracts
        if (!empty($report['message']) && !empty($report['evidence'])) {
            preg_match(
                '/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/',
                $report['message'],
                $matches
            );

            if (!empty($matches['ip']) && !empty($matches['date'])) {
                $report['Source-IP'] = $matches['ip'];
                $report['Received-Date'] = $matches['date'];

                $reports[] = $report;
            }

            /*
             * Why would you use a single format while you can use different formats huh Spamcop?
             * For spamvertized we need to do some magic to build the report correctly
             *             "(?<mole>\d+)\s+".
             */
            $report['message'] = str_replace('\r', '', $report['message']);
            preg_match(
                '/Spamvertised web site:\s'.
                '(?<url>.*)\\n'.
                '(?<reply>.*)\n'.
                '(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n'.
                '/',
                $report['message'],
                $matches
            );

            if (!empty($matches['ip']) && !empty($matches['date']) && !empty($matches['url'])) {
                $report['Source-IP'] = $matches['ip'];
                $report['Received-Date'] = $matches['date'];
                $report['Report-URL'] = $matches['reply'];
                $report['Spam-URL'] = $matches['url'];

                $reports[] = $report;
            }

        } else {
            $this->warningCount++;
        }

        return $reports;
    }
public function parseSpamReportCustom()
    {

        $reports = [ ];
        $body = $this->parsedMail->getMessageBody();

        // Grab the message part from the body
        preg_match(
            '/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s',
            $body,
            $matches
        );
        if (!empty($matches['message'])) {
            $report['message'] = $matches['message'];
        }

        // Grab the Evidence from the body
        preg_match(
            '/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s',
            $body,
            $matches
        );

        if (!empty($matches['evidence'])) {
            $parsedEvidence = new MimeParser();
            $parsedEvidence->setText($matches['evidence']);
            $report['evidence'] = $parsedEvidence->getHeaders();
        }

        // Now parse the data from both extracts
        if (!empty($report['message']) && !empty($report['evidence'])) {
            preg_match(
                '/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/',
                $report['message'],
                $matches
            );

            if (!empty($matches['ip']) && !empty($matches['date'])) {
                $report['Source-IP'] = $matches['ip'];
                $report['Received-Date'] = $matches['date'];

                $reports[] = $report;
            }

            /*
             * Why would you use a single format while you can use different formats huh Spamcop?
             * For spamvertized we need to do some magic to build the report correctly
             *             "(?<mole>\d+)\s+".
             */
            $report['message'] = str_replace('\r', '', $report['message']);
            preg_match(
                '/Spamvertised web site:\s'.
                '(?<url>.*)\\n'.
                '(?<reply>.*)\n'.
                '(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n'.
                '/',
                $report['message'],
                $matches
            );

            if (!empty($matches['ip']) && !empty($matches['date']) && !empty($matches['url'])) {
                $report['Source-IP'] = $matches['ip'];
                $report['Received-Date'] = $matches['date'];
                $report['Report-URL'] = $matches['reply'];
                $report['Spam-URL'] = $matches['url'];

                $reports[] = $report;
            }

        } else {
            $this->warningCount++;
        }

        return $reports;
    }
public function parseSpamReportCustom ( ) { $ reports = [ ] ; $ body = $ this -> parsedMail -> getMessageBody ( ) ; // Grab the message part from the body preg_match ( '/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s' , $ body , $ matches ) ; if ( ! empty ( $ matches [ 'message' ] ) ) { $ report [ 'message' ] = $ matches [ 'message' ] ; } // Grab the Evidence from the body preg_match ( '/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s' , $ body , $ matches ) ; if ( ! empty ( $ matches [ 'evidence' ] ) ) { $ parsedEvidence = new MimeParser ( ) ; $ parsedEvidence -> setText ( $ matches [ 'evidence' ] ) ; $ report [ 'evidence' ] = $ parsedEvidence -> getHeaders ( ) ; } // Now parse the data from both extracts if ( ! empty ( $ report [ 'message' ] ) && ! empty ( $ report [ 'evidence' ] ) ) { preg_match ( '/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/' , $ report [ 'message' ] , $ matches ) ; if ( ! empty ( $ matches [ 'ip' ] ) && ! empty ( $ matches [ 'date' ] ) ) { $ report [ 'Source-IP' ] = $ matches [ 'ip' ] ; $ report [ 'Received-Date' ] = $ matches [ 'date' ] ; $ reports [ ] = $ report ; } /*
             * Why would you use a single format while you can use different formats huh Spamcop?
             * For spamvertized we need to do some magic to build the report correctly
             *             "(?<mole>\d+)\s+".
             */ $ report [ 'message' ] = str_replace ( '\r' , '' , $ report [ 'message' ] ) ; preg_match ( '/Spamvertised web site:\s' . '(?<url>.*)\\n' . '(?<reply>.*)\n' . '(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n' . '/' , $ report [ 'message' ] , $ matches ) ; if ( ! empty ( $ matches [ 'ip' ] ) && ! empty ( $ matches [ 'date' ] ) && ! empty ( $ matches [ 'url' ] ) ) { $ report [ 'Source-IP' ] = $ matches [ 'ip' ] ; $ report [ 'Received-Date' ] = $ matches [ 'date' ] ; $ report [ 'Report-URL' ] = $ matches [ 'reply' ] ; $ report [ 'Spam-URL' ] = $ matches [ 'url' ] ; $ reports [ ] = $ report ; } } else { $ this -> warningCount ++ ; } return $ reports ; }
This is a spamcop formatted mail with a single incident

@return array $reports
This is a spamcop formatted mail with a single incident