<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>selfoss support forum - IMAP spout</title>
<link>https://forum.selfoss.aditu.de/</link>
<description>selfoss support forum</description>
<language>en</language>
<item>
<title>IMAP spout (reply)</title>
<content:encoded><![CDATA[<p>/*---- 2nd part ----*/</p>
<p>/**</p>
<p>     * returns an unique id for this item</p>
<p>     *</p>
<p>     * @return string id as hash</p>
<p>     */</p>
<p>    public function getId() {</p>
<p>        if($this-&gt;items!==false &amp;&amp; $this-&gt;valid()) {</p>
<p>            $id = @current($this-&gt;items)-&gt;get_id();</p>
<p>            if(strlen($id)&gt;255)</p>
<p>                $id = md5($id);</p>
<p>            return $id;</p>
<p>        }</p>
<p>        return false;</p>
<p>    }</p>
<p>    </p>
<p>    </p>
<p>    /**</p>
<p>     * returns the current title as string</p>
<p>     *</p>
<p>     * @return string title</p>
<p>     */</p>
<p>    public function getTitle() {</p>
<p>        if($this-&gt;items!==false &amp;&amp; $this-&gt;valid())</p>
<p>            return @current($this-&gt;items)-&gt;get_title();</p>
<p>        return false;</p>
<p>    }</p>
<p>    </p>
<p>    </p>
<p>    /**</p>
<p>     * returns the content of this item</p>
<p>     *</p>
<p>     * @return string content</p>
<p>     */</p>
<p>    public function getContent() {</p>
<p>        if($this-&gt;items!==false &amp;&amp; $this-&gt;valid())</p>
<p>            return @current($this-&gt;items)-&gt;get_content();</p>
<p>        return false;</p>
<p>    }</p>
<p>    </p>
<p>    /**</p>
<p>     * returns the date of this item</p>
<p>     *</p>
<p>     * @return string date</p>
<p>     */</p>
<p>    public function getDate() {</p>
<p>        if($this-&gt;items!==false &amp;&amp; $this-&gt;valid())</p>
<p>            $date = @current($this-&gt;items)-&gt;get_date();</p>
<p>        if(strlen($date)==0)</p>
<p>            $date = date('Y-m-d H:i:s');</p>
<p>        return $date;</p>
<p>    }</p>
<p>    <br />
     /**<br />
     * returns the global html url for the source<br />
     *<br />
     * @return string url as html<br />
     */<br />
    public function getHtmlUrl() {<br />
        if(isset($this-&gt;htmlUrl))<br />
            return $this-&gt;htmlUrl;<br />
        return false;<br />
    }</p>
<p>    /**<br />
     * returns the icon of this item<br />
     *<br />
     * @return string icon url<br />
     */<br />
    public function getIcon() {<br />
        if(isset($this-&gt;faviconUrl))<br />
            return $this-&gt;faviconUrl;<br />
        <br />
        $this-&gt;faviconUrl = false;<br />
        $imageHelper = $this-&gt;getImageHelper();<br />
        $htmlUrl = $this-&gt;getHtmlUrl();<br />
        if($htmlUrl &amp;&amp; $imageHelper-&gt;fetchFavicon($htmlUrl))<br />
            $this-&gt;faviconUrl = $imageHelper-&gt;getFaviconUrl();<br />
        return $this-&gt;faviconUrl;<br />
    }<br />
    <br />
    <br />
    /**<br />
     * returns the link of this item<br />
     *<br />
     * @return string link<br />
     */<br />
    public function getLink() {<br />
        if($this-&gt;items!==false &amp;&amp; $this-&gt;valid())<br />
            return @current($this-&gt;items)-&gt;get_link();<br />
        return false;<br />
    }</p>
<p>    /**</p>
<p>     * destroy the plugin (prevent memory issues)</p>
<p>     */</p>
<p>    public function destroy() {</p>
<p>        unset($this-&gt;items);</p>
<p>        $this-&gt;items = false;</p>
<p>    }</p>
<p>}</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=560</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=560</guid>
<pubDate>Tue, 09 Jul 2013 16:43:34 +0000</pubDate>
<dc:creator>morphiumdeus</dc:creator>
</item>
<item>
<title>IMAP spout (reply)</title>
<content:encoded><![CDATA[<p>Ok, so programmed a very simple (and very dirty) Email-Spout. It will only show the subject, date and html/plain body of a mail. No attachments, nothing else. Please do not judge me for not really implementing the get_icon, get_link and get_html... functions. And it has some problems with utf-8 or whatever conversion (help appreciated). I copied this in /spouts/mail/mail.php.</p>
<p>&lt;?PHP<br />
namespace spouts\mail;</p>
<p>class mailItem {<br />
 private $id;<br />
 private $title;<br />
 private $date;<br />
 private $content;<br />
 public function setId($id) {<br />
        $this-&gt;id = $id;<br />
    }<br />
 public function get_id() {<br />
        return $this-&gt;id;<br />
    }<br />
 public function setTitle($title) {<br />
        $this-&gt;title = $title;<br />
    }<br />
    public function get_title() {<br />
        return $this-&gt;title;<br />
    }<br />
 public function setDate($date) {<br />
        $this-&gt;date = $date;<br />
    }<br />
 public function get_date() {<br />
        return date('Y-m-d H:i:s', $this-&gt;date);<br />
    }<br />
 public function setContent($content) {<br />
        $this-&gt;content = $content;<br />
    }<br />
 public function get_content() {<br />
        return $this-&gt;content;<br />
    }<br />
 public function get_link() {<br />
        return $this-&gt;title;<br />
    }<br />
 public function getHtmlUrl() {<br />
        return $this-&gt;title;<br />
    }<br />
}</p>
<p>class mail extends \spouts\spout {<br />
    public $name = 'Email';<br />
    public $description = 'email imap account as source';<br />
    public $params = array(<br />
            &quot;email&quot; =&gt; array(<br />
            &quot;title&quot;      =&gt; &quot;Email&quot;,<br />
            &quot;type&quot;       =&gt; &quot;text&quot;,<br />
            &quot;default&quot;    =&gt; &quot;&quot;,<br />
            &quot;required&quot;   =&gt; true,<br />
            &quot;validation&quot; =&gt; array(&quot;email&quot;)<br />
        ),<br />
        &quot;password&quot; =&gt; array(<br />
            &quot;title&quot;      =&gt; &quot;Password&quot;,<br />
            &quot;type&quot;       =&gt; &quot;password&quot;,<br />
            &quot;default&quot;    =&gt; &quot;&quot;,<br />
            &quot;required&quot;   =&gt; true,<br />
            &quot;validation&quot; =&gt; array(&quot;notempty&quot;)<br />
        ),<br />
        &quot;host&quot; =&gt; array(<br />
            &quot;title&quot;      =&gt; &quot;URL&quot;,<br />
            &quot;type&quot;       =&gt; &quot;text&quot;,<br />
            &quot;default&quot;    =&gt; &quot;{imap.one.com:993/service=imap/ssl}INBOX&quot;,<br />
            &quot;required&quot;   =&gt; true,<br />
            &quot;validation&quot; =&gt; array(&quot;notempty&quot;)<br />
        )<br />
    );</p>
<p>    </p>
<p>    /**</p>
<p>     * current fetched items</p>
<p>     *</p>
<p>     * @var array|bool</p>
<p>     */</p>
<p>    protected $items = false;</p>
<p>    </p>
<p>    </p>
<p>    //</p>
<p>    // Iterator Interface</p>
<p>    //</p>
<p>    </p>
<p>    /**</p>
<p>     * reset iterator</p>
<p>     *</p>
<p>     * @return void</p>
<p>     */</p>
<p>    public function rewind() {</p>
<p>        if($this-&gt;items!==false)</p>
<p>            reset($this-&gt;items);</p>
<p>    }</p>
<p>    </p>
<p>    /**</p>
<p>     * receive current item</p>
<p>     *</p>
<p>     * @return current item</p>
<p>     */</p>
<p>    public function current() {</p>
<p>        if($this-&gt;items!==false)</p>
<p>            return $this;</p>
<p>        return false;</p>
<p>    }</p>
<p>    </p>
<p>    /**</p>
<p>     * receive key of current item</p>
<p>     *</p>
<p>     * @return mixed key of current item</p>
<p>     */</p>
<p>    public function key() {</p>
<p>        if($this-&gt;items!==false)</p>
<p>            return key($this-&gt;items);</p>
<p>        return false;</p>
<p>    }</p>
<p>    </p>
<p>    /**</p>
<p>     * select next item</p>
<p>     *</p>
<p>     * @return next item</p>
<p>     */</p>
<p>    public function next() {</p>
<p>        if($this-&gt;items!==false)</p>
<p>            next($this-&gt;items);</p>
<p>        return $this;</p>
<p>    }</p>
<p>    </p>
<p>    /**</p>
<p>     * end reached</p>
<p>     *</p>
<p>     * @return bool false if end reached</p>
<p>     */</p>
<p>    public function valid() {</p>
<p>        if($this-&gt;items!==false)</p>
<p>            return current($this-&gt;items) !== false;</p>
<p>        return false;</p>
<p>    }</p>
<p>    </p>
<p>    //</p>
<p>    // Source Methods</p>
<p>    //</p>
<p>    </p>
<p>    /**</p>
<p>     * loads content for given source</p>
<p>     *</p>
<p>     * @return void</p>
<p>     * @param mixed $params the params of this source</p>
<p>     */</p>
<p>    public function load($params) {</p>
<p>        // initialize <br />
   $mails = '';<br />
   $mbox = imap_open($params[&quot;host&quot;],$params[&quot;email&quot;],$params[&quot;password&quot;]) or die(&quot;Could not open Mailbox - try again later!&quot;);<br />
   $message_count = imap_num_msg($mbox);<br />
   for ($i = 1; $i &lt;= $message_count; ++$i) {<br />
    $thisMail = new mailItem();<br />
    $thisMail-&gt;setTitle(quoted_printable_decode(imap_header($mbox, $i)-&gt;subject));<br />
          $thisMail-&gt;setDate(imap_header($mbox, $i)-&gt;udate);<br />
    $thisMail-&gt;setId(imap_header($mbox, $i)-&gt;message_id);<br />
    $struct = imap_fetchstructure($mbox, $i, $options = null);<br />
    if(isset($struct-&gt;parts)) {<br />
      foreach($struct-&gt;parts as $key =&gt; $value) {<br />
       if(strtoupper($value-&gt;subtype) == &quot;HTML&quot;){<br />
        $thisMail-&gt;setContent(quoted_printable_decode(imap_fetchbody($mbox, $i, $key))); <br />
       }<br />
      }<br />
     }<br />
    else $thisMail-&gt;setContent(quoted_printable_decode(imap_fetchbody($mbox, $i, &quot;1&quot;)));<br />
    $mails[]=$thisMail;<br />
   }<br />
   imap_close($mbox); <br />
        </p>
<p><br />
        // save fetched items</p>
<p>        $this-&gt;items = @$mails;</p>
<p>    }</p>
<p>/*----Please continue with 2nd part----*/</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=559</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=559</guid>
<pubDate>Tue, 09 Jul 2013 16:43:03 +0000</pubDate>
<dc:creator>morphiumdeus</dc:creator>
</item>
<item>
<title>IMAP spout</title>
<content:encoded><![CDATA[<p>Hello,<br />
has someone already implemented a IMAP spout as described on the homepage? I could really use this. I'm not too good with php, but otherwise I would try to hack it myself...<br />
Thanks, md</p>
]]></content:encoded>
<link>https://forum.selfoss.aditu.de/index.php?id=555</link>
<guid>https://forum.selfoss.aditu.de/index.php?id=555</guid>
<pubDate>Tue, 09 Jul 2013 12:48:29 +0000</pubDate>
<dc:creator>morphiumdeus</dc:creator>
</item>
</channel>
</rss>
