Hi,
I am still working on dokuroam (
https://github.com/andjar/dokuroam), and made this short script to fetch unseen emails with [note] in the subject line (the emails are then marked as seen to prevent them from being added several times), add the page to the note namespace with the time sent as file name, and tagged with note, mail and today's date. Finally it rebuilds the index.
<?php
set_time_limit(4000);
$imapPath = '{imap.gmail.com:993/ssl/novalidate-cert}INBOX';
$username = 'username@gmail.com';
$password = 'password';
// try to connect
$inbox = imap_open($imapPath,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
// search and get unseen emails, function will return email ids
$emails = imap_search($inbox,'SUBJECT [note] FROM ' . $username . ' UNSEEN');
foreach($emails as $mail) {
$hinfo = imap_headerinfo($inbox,$mail);
$stime = $hinfo->date;
$mailtext = imap_fetchbody($inbox, $mail, 1);
$link = $_SERVER['DOCUMENT_ROOT'] . '/data/pages/notes/' . date('Ymd-Hmi',strtotime($stime)) . '-mail.txt';
echo $link;
$mailtext = $mailtext . PHP_EOL . PHP_EOL . '{{tag>mail note ' . date("Ymd") . '}}';
$status = file_put_contents($link, $mailtext);
}
// close the connection
imap_expunge($inbox);
imap_close($inbox);
execute('sudo -u www-data ' . $_SERVER['DOCUMENT_ROOT'] . '/bin/indexer.php');
?>