+
+ case NETWORK_MAIL:
+
+ if(get_config('system','dfrn_only'))
+ break;
+
+ // WARNING: does not currently convert to RFC2047 header encodings, etc.
+
+ $addr = $contact['addr'];
+ if(! strlen($addr))
+ break;
+
+ if($cmd === 'wall-new' || $cmd === 'comment-new') {
+
+ $it = null;
+ if($cmd === 'wall-new')
+ $it = $items[0];
+ else {
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($argv[2]),
+ intval($uid)
+ );
+ if(count($r))
+ $it = $r[0];
+ }
+ if(! $it)
+ break;
+
+
+
+ $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+ if(! count($local_user))
+ break;
+
+ $reply_to = '';
+ $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+ if($r1 && $r1[0]['reply_to'])
+ $reply_to = $r1[0]['reply_to'];
+
+ $subject = (($it['title']) ? $it['title'] : t("\x28no subject\x29")) ;
+ $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n";
+
+ if($reply_to)
+ $headers .= 'Reply-to: ' . $reply_to . "\n";
+
+ $headers .= 'Message-id: <' . $it['uri'] . '>' . "\n";
+
+ if($it['uri'] !== $it['parent-uri']) {
+ $header .= 'References: <' . $it['parent-uri'] . '>' . "\n";
+ if(! strlen($it['title'])) {
+ $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
+ dbesc($it['parent-uri'])
+ );
+ if(count($r)) {
+ $subtitle = $r[0]['title'];
+ if($subtitle) {
+ if(strncasecmp($subtitle,'RE:',3))
+ $subject = $subtitle;
+ else
+ $subject = 'Re: ' . $subtitle;
+ }
+ }
+ }
+ }
+
+ $headers .= 'MIME-Version: 1.0' . "\n";
+ $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
+ $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
+ $html = prepare_body($it);
+ $message = '<html><body>' . $html . '</body></html>';
+ logger('notifier: email delivery to ' . $addr);
+ mail($addr, $subject, $message, $headers);
+ }
+ break;
+ case NETWORK_DIASPORA:
+ require_once('include/diaspora.php');
+ if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
+ break;
+
+ if(! $contact['pubkey'])
+ break;
+
+ if($target_item['verb'] === ACTIVITY_DISLIKE) {
+ // unsupported
+ break;
+ }
+ elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
+ // diaspora delete,
+ diaspora_send_retraction($target_item,$owner,$contact);
+ break;
+ }
+ elseif($followup) {
+ // send comments, likes and retractions of likes to owner to relay
+ diaspora_send_followup($target_item,$owner,$contact);
+ break;
+ }
+ elseif($target_item['parent'] != $target_item['id']) {
+ // we are the relay - send comments, likes and unlikes to our conversants
+ diaspora_send_relay($target_item,$owner,$contact);
+ break;
+ }
+ elseif(($top_level) && (! $walltowall)) {
+ // currently no workable solution for sending walltowall
+ diaspora_send_status($target_item,$owner,$contact);
+ break;
+ }
+
+ break;
+
+ case NETWORK_FEED:
+ case NETWORK_FACEBOOK:
+ if(get_config('system','dfrn_only'))
+ break;