multipart messages complete, message-id conversion done.
This commit is contained in:
parent
0ba45eb745
commit
a74b0746b1
|
@ -438,14 +438,14 @@ function delivery_run($argv, $argc){
|
||||||
$file = tempnam("/tmp/friendica/", "mail-out-");
|
$file = tempnam("/tmp/friendica/", "mail-out-");
|
||||||
file_put_contents($file, json_encode($it));
|
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: 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_DEBUG);
|
||||||
//logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
|
//logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
|
||||||
|
|
||||||
if($it['uri'] !== $it['parent-uri']) {
|
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'])) {
|
if(! strlen($it['title'])) {
|
||||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
||||||
dbesc($it['parent-uri'])
|
dbesc($it['parent-uri'])
|
||||||
|
|
|
@ -232,24 +232,27 @@ function email_send($addr, $subject, $headers, $item) {
|
||||||
//$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
|
//$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
|
||||||
//$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
|
//$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
|
||||||
//$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
|
//$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
|
||||||
|
|
||||||
|
$part = uniqid("", true);
|
||||||
|
|
||||||
$html = prepare_body($item);
|
$html = prepare_body($item);
|
||||||
|
|
||||||
$headers .= "Mime-Version: 1.0\n";
|
$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 = "\n--=_".$part."\n";
|
||||||
$body .= "Content-Transfer-Encoding: quoted-printable\n";
|
$body .= "Content-Transfer-Encoding: 8bit\n";
|
||||||
$body .= "Content-Type: text/plain; charset=utf-8; format=flowed\n\n";
|
$body .= "Content-Type: text/plain; charset=utf-8; format=flowed\n\n";
|
||||||
|
|
||||||
$body .= html2plain($html)."\n";
|
$body .= html2plain($html)."\n";
|
||||||
|
|
||||||
$body .= "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a\n";
|
$body .= "--=_".$part."\n";
|
||||||
$body .= "Content-Transfer-Encoding: quoted-printable\n";
|
$body .= "Content-Transfer-Encoding: 8bit\n";
|
||||||
$body .= "Content-Type: text/html; charset=utf-8\n\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 = '<html><body>' . $html . '</body></html>';
|
||||||
//$message = html2plain($html);
|
//$message = html2plain($html);
|
||||||
|
@ -257,12 +260,18 @@ function email_send($addr, $subject, $headers, $item) {
|
||||||
mail($addr, $subject, $body, $headers);
|
mail($addr, $subject, $body, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
function email_cleanupmessageid($messageid) {
|
function iri2msgid($iri) {
|
||||||
global $a;
|
if (!strpos($iri, "@"))
|
||||||
|
$msgid = preg_replace("/urn:(\S+):(\S+)\.(\S+):(\d+):(\S+)/i", "urn!$1!$4!$5@$2.$3", $iri);
|
||||||
if (!strpos($messageid, '@'))
|
else
|
||||||
$messageid = str_replace(":", ".", $messageid).'@'.$a->get_hostname();
|
$msgid = $iri;
|
||||||
|
return($msgid);
|
||||||
return($messageid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -651,10 +651,10 @@ function notifier_run($argv, $argc){
|
||||||
$file = tempnam("/tmp/friendica/", "mail-out2-");
|
$file = tempnam("/tmp/friendica/", "mail-out2-");
|
||||||
file_put_contents($file, json_encode($it));
|
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']) {
|
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'])) {
|
if(! strlen($it['title'])) {
|
||||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
||||||
dbesc($it['parent-uri'])
|
dbesc($it['parent-uri'])
|
||||||
|
|
|
@ -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.
|
// 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']) : '');
|
$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) {
|
if($raw_refs) {
|
||||||
$refs_arr = explode(' ', $raw_refs);
|
$refs_arr = explode(' ', $raw_refs);
|
||||||
if(count($refs_arr)) {
|
if(count($refs_arr)) {
|
||||||
for($x = 0; $x < count($refs_arr); $x ++)
|
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);
|
$qstr = implode(',',$refs_arr);
|
||||||
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1",
|
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE `uri` IN ( $qstr ) AND `uid` = %d LIMIT 1",
|
||||||
|
|
Loading…
Reference in a new issue