Last active
February 21, 2024 07:16
-
-
Save okuramasafumi/eecf97b3b1b459b0564a to your computer and use it in GitHub Desktop.
iCloud IMAP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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