]> git.mxchange.org Git - friendica.git/commitdiff
multipart messages complete, message-id conversion done.
authorMichael <icarus@dabo.de>
Sat, 25 Feb 2012 00:10:45 +0000 (01:10 +0100)
committerMichael <icarus@dabo.de>
Sat, 25 Feb 2012 00:10:45 +0000 (01:10 +0100)
include/delivery.php
include/email.php
include/notifier.php
include/poller.php

index 98c4f75df25e540925ef835443b42a5a6eaf0123..97a76965a7b6c187e6a4d6753728275be5bc00b6 100755 (executable)
@@ -438,14 +438,14 @@ function delivery_run($argv, $argc){
                                $file = tempnam("/tmp/friendica/", "mail-out-");
                                file_put_contents($file, json_encode($it));
 
-                               $headers .= 'Message-Id: <' . email_cleanupmessageid($it['uri']). '>' . "\n";
+                               $headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n";
 
                                //logger("Mail: uri: ".$it['uri']." parent-uri ".$it['parent-uri'], LOGGER_DEBUG);
                                //logger("Mail: Data: ".print_r($it, true), LOGGER_DEBUG);
                                //logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
 
                                if($it['uri'] !== $it['parent-uri']) {
-                                       $headers .= 'References: <' . email_cleanupmessageid($it['parent-uri']) . '>' . "\n";
+                                       $headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
                                        if(! strlen($it['title'])) {
                                                $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
                                                        dbesc($it['parent-uri'])
index fee3e2f6860a4b177f676d4d92322f705f49631b..4fc241f248022291aa8d035e41da4532aaee16ec 100755 (executable)
@@ -232,24 +232,27 @@ function email_send($addr, $subject, $headers, $item) {
        //$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
        //$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
        //$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
+
+       $part = uniqid("", true);
+
        $html    = prepare_body($item);
 
        $headers .= "Mime-Version: 1.0\n";
-       $headers .= 'Content-Type: multipart/alternative; boundary="=_1f5dbdf8dbd0a060ea5bc3050bb14c6a"'."\n\n";
+       $headers .= 'Content-Type: multipart/alternative; boundary="=_'.$part.'"'."\n\n";
 
-       $body = "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a\n";
-       $body .= "Content-Transfer-Encoding: quoted-printable\n";
+       $body = "\n--=_".$part."\n";
+       $body .= "Content-Transfer-Encoding: 8bit\n";
        $body .= "Content-Type: text/plain; charset=utf-8; format=flowed\n\n";
 
        $body .= html2plain($html)."\n";
 
-       $body .= "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a\n";
-       $body .= "Content-Transfer-Encoding: quoted-printable\n";
+       $body .= "--=_".$part."\n";
+       $body .= "Content-Transfer-Encoding: 8bit\n";
        $body .= "Content-Type: text/html; charset=utf-8\n\n";
 
-       $body .= $html."\n\n";
+       $body .= '<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">'.$html."</body></html>\n";
 
-       $body .= "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a--\n";
+       $body .= "--=_".$part."--";
 
        //$message = '<html><body>' . $html . '</body></html>';
        //$message = html2plain($html);
@@ -257,12 +260,18 @@ function email_send($addr, $subject, $headers, $item) {
        mail($addr, $subject, $body, $headers);
 }
 
-function email_cleanupmessageid($messageid) {
-       global $a;
-
-       if (!strpos($messageid, '@'))
-               $messageid = str_replace(":", ".", $messageid).'@'.$a->get_hostname();
-
-       return($messageid);
+function iri2msgid($iri) {
+       if (!strpos($iri, "@"))
+               $msgid = preg_replace("/urn:(\S+):(\S+)\.(\S+):(\d+):(\S+)/i", "urn!$1!$4!$5@$2.$3", $iri);
+       else
+               $msgid = $iri;
+       return($msgid);
 }
 
+function msgid2iri($msgid) {
+       if (strpos($msgid, "@"))
+               $iri = preg_replace("/urn!(\S+)!(\d+)!(\S+)@(\S+)\.(\S+)/i", "urn:$1:$4.$5:$2:$3", $msgid);
+       else
+               $iri = $msgid;
+       return($iri);
+}
index b22e8c6f03de54ca8f99dfdb47faf0dc096ed9b5..684395da6ca4c1044abaa81aed4db8a4f36ebf80 100755 (executable)
@@ -651,10 +651,10 @@ function notifier_run($argv, $argc){
                                                $file = tempnam("/tmp/friendica/", "mail-out2-");
                                                file_put_contents($file, json_encode($it));
 
-                                               $headers .= 'Message-Id: <' . email_cleanupmessageid($it['uri']) . '>' . "\n";
+                                               $headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n";
 
                                                if($it['uri'] !== $it['parent-uri']) {
-                                                       $headers .= 'References: <' . email_cleanupmessageid($it['parent-uri']) . '>' . "\n";
+                                                       $headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
                                                        if(! strlen($it['title'])) {
                                                                $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
                                                                        dbesc($it['parent-uri'])
index ad15ec24446c37bc9933c5a0f948e358d6e58fbc..9cf12ed9cdfc2993c7acb3b250251800a54dc3d1 100755 (executable)
@@ -420,13 +420,13 @@ function poller_run($argv, $argc){
                                                        // look for a 'references' header and try and match with a parent item we have locally.
 
                                                        $raw_refs = ((x($headers,'references')) ? str_replace("\t",'',$headers['references']) : '');
-                                                       $datarray['uri'] = trim($meta->message_id,'<>');
+                                                       $datarray['uri'] = msgid2iri(trim($meta->message_id,'<>'));
 
                                                        if($raw_refs) {
                                                                $refs_arr = explode(' ', $raw_refs);
                                                                if(count($refs_arr)) {
                                                                        for($x = 0; $x < count($refs_arr); $x ++)
-                                                                               $refs_arr[$x] = "'" . str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x])) . "'";
+                                                                               $refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'";
                                                                }
                                                                $qstr = implode(',',$refs_arr);
                                                                $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1",