src/Spamcop.php
public function parseSpamReportArf()
    {
        $reports = [ ];

        //Seriously spamcop? Newlines arent in the CL specifications
        $this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']);

        preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $this->arfMail['report'], $regs);
        $report = array_combine($regs[1], $regs[2]);

        //Valueable information put in the body instead of the report, thnx for that Spamcop
        if (strpos($this->arfMail['message'], 'Comments from recipient') !== false) {
            preg_match(
                "/Comments from recipient.*\s]\n(.*)\n\n\nThis/s",
                str_replace(array("\r", "> "), "", $this->arfMail['message']),
                $match
            );
            $report['recipient_comment'] = str_replace("\n", " ", $match[1]);
        }

        // Add the headers from evidence into infoblob
        $parsedEvidence = new MimeParser();
        $parsedEvidence->setText($this->arfMail['evidence']);
        $headers = $parsedEvidence->getHeaders();

        foreach ($headers as $key => $value) {
            if (is_array($value) || is_object(($value))) {
                foreach ($value as $index => $subvalue) {
                    $report['headers']["${key}${index}"] = "$subvalue";
                }
            } else {
                $report['headers']["$key"] = $value;
            }
        }

        /*
         * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty
         * normal to add. In a last attempt we will try to fetch the IP from the body ourselves
         */
        if (empty($report['Source-IP'])) {
            preg_match(
                "/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote($report['Received-Date']) . "/s",
                $this->arfMail['message'],
                $regs
            );

            if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
                $report['Source-IP'] = $regs['ip'];
            }

            preg_match(
                "/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s",
                $this->parsedMail->getMessageBody(),
                $regs
            );

            if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
                $report['Source-IP'] = $regs['ip'];
            }
        }

        $reports[] = $report;

        return $reports;
    }
public function parseSpamReportArf()
    {
        $reports = [ ];

        //Seriously spamcop? Newlines arent in the CL specifications
        $this->arfMail['report'] = str_replace("\r", "", $this->arfMail['report']);

        preg_match_all('/([\w\-]+): (.*)[ ]*\r?\n/', $this->arfMail['report'], $regs);
        $report = array_combine($regs[1], $regs[2]);

        //Valueable information put in the body instead of the report, thnx for that Spamcop
        if (strpos($this->arfMail['message'], 'Comments from recipient') !== false) {
            preg_match(
                "/Comments from recipient.*\s]\n(.*)\n\n\nThis/s",
                str_replace(array("\r", "> "), "", $this->arfMail['message']),
                $match
            );
            $report['recipient_comment'] = str_replace("\n", " ", $match[1]);
        }

        // Add the headers from evidence into infoblob
        $parsedEvidence = new MimeParser();
        $parsedEvidence->setText($this->arfMail['evidence']);
        $headers = $parsedEvidence->getHeaders();

        foreach ($headers as $key => $value) {
            if (is_array($value) || is_object(($value))) {
                foreach ($value as $index => $subvalue) {
                    $report['headers']["${key}${index}"] = "$subvalue";
                }
            } else {
                $report['headers']["$key"] = $value;
            }
        }

        /*
         * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty
         * normal to add. In a last attempt we will try to fetch the IP from the body ourselves
         */
        if (empty($report['Source-IP'])) {
            preg_match(
                "/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote($report['Received-Date']) . "/s",
                $this->arfMail['message'],
                $regs
            );

            if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
                $report['Source-IP'] = $regs['ip'];
            }

            preg_match(
                "/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s",
                $this->parsedMail->getMessageBody(),
                $regs
            );

            if (!empty($regs['ip']) && !filter_var($regs['ip'], FILTER_VALIDATE_IP) === false) {
                $report['Source-IP'] = $regs['ip'];
            }
        }

        $reports[] = $report;

        return $reports;
    }
public function parseSpamReportArf ( ) { $ reports = [ ] ; //Seriously spamcop? Newlines arent in the CL specifications $ this -> arfMail [ 'report' ] = str_replace ( "\r" , "" , $ this -> arfMail [ 'report' ] ) ; preg_match_all ( '/([\w\-]+): (.*)[ ]*\r?\n/' , $ this -> arfMail [ 'report' ] , $ regs ) ; $ report = array_combine ( $ regs [ 1 ] , $ regs [ 2 ] ) ; //Valueable information put in the body instead of the report, thnx for that Spamcop if ( strpos ( $ this -> arfMail [ 'message' ] , 'Comments from recipient' ) !== false ) { preg_match ( "/Comments from recipient.*\s]\n(.*)\n\n\nThis/s" , str_replace ( array ( "\r" , "> " ) , "" , $ this -> arfMail [ 'message' ] ) , $ match ) ; $ report [ 'recipient_comment' ] = str_replace ( "\n" , " " , $ match [ 1 ] ) ; } // Add the headers from evidence into infoblob $ parsedEvidence = new MimeParser ( ) ; $ parsedEvidence -> setText ( $ this -> arfMail [ 'evidence' ] ) ; $ headers = $ parsedEvidence -> getHeaders ( ) ; foreach ( $ headers as $ key => $ value ) { if ( is_array ( $ value ) || is_object ( ( $ value ) ) ) { foreach ( $ value as $ index => $ subvalue ) { $ report [ 'headers' ] [ "${key}${index}" ] = "$subvalue" ; } } else { $ report [ 'headers' ] [ "$key" ] = $ value ; } } /*
         * Sometimes Spamcop has a trouble adding the correct fields. The IP is pretty
         * normal to add. In a last attempt we will try to fetch the IP from the body ourselves
         */ if ( empty ( $ report [ 'Source-IP' ] ) ) { preg_match ( "/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote ( $ report [ 'Received-Date' ] ) . "/s" , $ this -> arfMail [ 'message' ] , $ regs ) ; if ( ! empty ( $ regs [ 'ip' ] ) && ! filter_var ( $ regs [ 'ip' ] , FILTER_VALIDATE_IP ) === false ) { $ report [ 'Source-IP' ] = $ regs [ 'ip' ] ; } preg_match ( "/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s" , $ this -> parsedMail -> getMessageBody ( ) , $ regs ) ; if ( ! empty ( $ regs [ 'ip' ] ) && ! filter_var ( $ regs [ 'ip' ] , FILTER_VALIDATE_IP ) === false ) { $ report [ 'Source-IP' ] = $ regs [ 'ip' ] ; } } $ reports [ ] = $ report ; return $ reports ; }
This is a ARF mail with a single incident

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