<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
    /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
    _paq.push(['trackPageView']);
    _paq.push(['enableLinkTracking']);
      (function() {
	          var u="//analytics.wasya.co/";
		      _paq.push(['setTrackerUrl', u+'matomo.php']);
		      _paq.push(['setSiteId', '15']);
		          var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
		          g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
			    })();
    </script>
<!-- End Matomo Code -->
<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.wasya.co/index.php?action=history&amp;feed=atom&amp;title=Imap</id>
		<title>Imap - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.wasya.co/index.php?action=history&amp;feed=atom&amp;title=Imap"/>
		<link rel="alternate" type="text/html" href="https://wiki.wasya.co/index.php?title=Imap&amp;action=history"/>
		<updated>2026-05-05T13:31:51Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.0</generator>

	<entry>
		<id>https://wiki.wasya.co/index.php?title=Imap&amp;diff=3279&amp;oldid=prev</id>
		<title>Piousbox: Created page with &quot;  https://docker-mailserver.github.io/docker-mailserver/edge/usage/   https://mdesantis.github.io/ruby-rails-documentations/Ruby%20v2.0.0-p451,%20Ruby%20on%20Rails%20v3.1.12/R...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.wasya.co/index.php?title=Imap&amp;diff=3279&amp;oldid=prev"/>
				<updated>2025-05-11T04:13:02Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;  https://docker-mailserver.github.io/docker-mailserver/edge/usage/   https://mdesantis.github.io/ruby-rails-documentations/Ruby%20v2.0.0-p451,%20Ruby%20on%20Rails%20v3.1.12/R...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;  https://docker-mailserver.github.io/docker-mailserver/edge/usage/&lt;br /&gt;
  https://mdesantis.github.io/ruby-rails-documentations/Ruby%20v2.0.0-p451,%20Ruby%20on%20Rails%20v3.1.12/Ruby/classes/Net/IMAP.html&lt;br /&gt;
  https://github.com/ruby/net-imap&lt;br /&gt;
  https://github.com/zquestz/omniauth-google-oauth2&lt;br /&gt;
  https://pramodbshinde.wordpress.com/2014/12/07/gmail-api-in-ruby-on-rails-a-piece-of-cake/&lt;br /&gt;
  https://dcparker.github.io/ruby-gmail/&lt;br /&gt;
  https://stackoverflow.com/questions/9039237/searching-all-mail-including-inbox-and-archived-emails-using-gmail-gem&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  imap = Net::IMAP.new('imap.gmail.com', 993, usessl = true, certs = nil, verify = false)&lt;br /&gt;
  imap.authenticate('XOAUTH2', email, access_token)&lt;br /&gt;
  imap.select(&amp;quot;[Gmail]/All Mail&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  imap = Net::IMAP.new('imap.gmail.com', 993, usessl = true, certs = nil, verify = false)&lt;br /&gt;
  imap.authenticate('LOGIN', '&amp;lt;user&amp;gt;', '&amp;lt;password&amp;gt;&amp;gt;')&lt;br /&gt;
  imap.examine('INBOX')&lt;br /&gt;
  imap.search([&amp;quot;RECENT&amp;quot;]).each do |message_id|&lt;br /&gt;
    envelope = imap.fetch(message_id, &amp;quot;ENVELOPE&amp;quot;)[0].attr[&amp;quot;ENVELOPE&amp;quot;]&lt;br /&gt;
    puts &amp;quot;#{envelope.from[0].name}: \t#{envelope.subject}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  imap = Net::IMAP.new('localhost', 143, usessl = false, certs = nil, verify = false)&lt;br /&gt;
  imap.authenticate('LOGIN', 'admin@email.local', 'test1234')&lt;br /&gt;
  imap.list('*', '*')&lt;br /&gt;
  imap.select('INBOX')&lt;br /&gt;
&lt;br /&gt;
  imap.search(['ALL']).each_with_index do |m_id, idx|&lt;br /&gt;
    break if idx &amp;gt; 10&lt;br /&gt;
    puts m_id&lt;br /&gt;
    msg = imap.fetch(m_id,'RFC822')[0].attr['RFC822']&lt;br /&gt;
    mail = Mail.read_from_string msg&lt;br /&gt;
    # puts!( mail.text_part.body.to_s, 'mail' ) rescue nil&lt;br /&gt;
    puts! mail.subject, 'subj'&lt;br /&gt;
    imap.store(m_id, '+FLAGS', [:Seen])&lt;br /&gt;
    imap.move(m_id, &amp;quot;Done&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  imap.search(['ALL']).each do |message_id|&lt;br /&gt;
    msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']&lt;br /&gt;
    mail = Mail.read_from_string msg&lt;br /&gt;
    puts mail.subject&lt;br /&gt;
    puts mail.text_part.body.to_s rescue nil&lt;br /&gt;
    puts mail.html_part.body.to_s rescue nil&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Piousbox</name></author>	</entry>

	</feed>