aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinclude/delivery.php4
-rwxr-xr-xinclude/email.php37
-rwxr-xr-xinclude/notifier.php4
-rwxr-xr-xinclude/poller.php4
4 files changed, 29 insertions, 20 deletions
diff --git a/include/delivery.php b/include/delivery.php
index 98c4f75df..97a76965a 100755
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -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'])
diff --git a/include/email.php b/include/email.php
index fee3e2f68..4fc241f24 100755
--- a/include/email.php
+++ b/include/email.php
@@ -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);
+}
diff --git a/include/notifier.php b/include/notifier.php
index b22e8c6f0..684395da6 100755
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -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'])
diff --git a/include/poller.php b/include/poller.php
index ad15ec244..9cf12ed9c 100755
--- a/include/poller.php
+++ b/include/poller.php
@@ -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",