fetch gmail with oauth2
Nope, just OAuth 1.0 right now.
Gmail SMTP + XOAuth mystery
The problem is on how you do the SMTP connection here is a snippet from my code:
smtp_conn = smtplib.SMTP('smtp.googlemail.com', 587)
#smtp_conn.set_debuglevel(True)
smtp_conn.ehlo()
smtp_conn.starttls()
smtp_conn.ehlo()
smtp_conn.docmd('AUTH', 'XOAUTH ' + base64.b64encode(xoauth_string))
You create the xoauth_string as in the example from Google. After that you can use smtp_conn to send your email. If you have any problems let me know. You can find some sample code at https://github.com/PanosJee/xoauth
How to read the body text of an email using ruby's net/imap library?
If you just want just the body content of the message you can use:
body = imap.fetch(message_id,'BODY[TEXT]')[0].attr['BODY[TEXT]']
The IMAP API is a bit esoteric though. If you want to deal with the whole message, I would recommend using TMail to parse it into an easier to use format:
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
mail = TMail::Mail.parse(msg)
body = mail.body
Related Topics
Grit's Clone Method Is Undefined
Search for "Enabled" Users in Net-Ldap for Ruby
Requiring a Ruby Gem in Ruby Script Breaks Cron Job Execution
Compass Error for Command 'Grunt Server'
Why Does Date.Yesterday Counts as Date.Today Also
Require Command Not Working Within Bash Irb on Snow Leopard
Ruby's Argv Can Be Empty on Windows Depending on a Way to Run Script
How to Write Down the Rspec to Test Rescue Block
Vagrant Ssh Not Working in Mobaxterm on Windows
Importing CSV Data into Rails App, Using Something Other Then the Association "Id"
Ruby: Cannot Install Watir Gem on Windows
How to Make a Ruby Script Using Trollop for Command Line Parsing
Why Is 032 Different Than 32 in Ruby
Require Ruby File Without .Rb Extension
How to Enable Colors with Rspec When Using Jruby or Bundle Exec