Skip to content

Instantly share code, notes, and snippets.

@okuramasafumi
Last active February 21, 2024 07:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save okuramasafumi/eecf97b3b1b459b0564a to your computer and use it in GitHub Desktop.
Save okuramasafumi/eecf97b3b1b459b0564a to your computer and use it in GitHub Desktop.
iCloud IMAP
# Simple script to fetch IMAP data from iCloud
# Set ICLOUD_EMAIL and ICLOUD_PASSWORD to environment variables
require 'net/imap'
require 'active_support'
imap = Net::IMAP.new('imap.mail.me.com', 993, true)
imap.login(ENV['ICLOUD_EMAIL'], ENV['ICLOUD_PASSWORD'])
imap.select 'INBOX'
uids = imap.uid_search(['SINCE', 1.week.ago.strftime('%d-%b-%Y')])
fetch_datas = imap.uid_fetch(uids, ['RFC822', 'RFC822.HEADER'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment