Net::IMAP::Multiappend
Adds IMAP MULTIAPPEND to the net-imap gem.
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add net-imap-multiappend
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install net-imap-multiappend
Example Usage
Use Podman to run a test IMAP server
podman run --detach --env=MAILNAME=example.com --env=MAIL_ADDRESS=address@example.com --env=MAIL_PASS=pass -p 7993:993 antespi/docker-imap-devel:latest
...or use Docker
docker run --detach --env=MAILNAME=example.com --env=MAIL_ADDRESS=address@example.com --env=MAIL_PASS=pass -p 7993:993 antespi/docker-imap-devel:latest
In the root directory of this project, install dependencies
bundle
Run a Ruby shell
pry
Connect
> require "net/imap/multiappend"
> imap = Net::IMAP.new("localhost", {port: 7993, ssl: {verify_mode:0}})
> imap.login("address@example.com", "pass")
Check the server accepts MULTIAPPEND
> imap.can_multiappend?
Send two messages
> m1 = Net::IMAP::Multiappend::Message.new("From: me\r\n\r\nHi 1\r\n")
> m2 = Net::IMAP::Multiappend::Message.new("From: me\r\n\r\nHi 2\r\n", flags: [:Seen])
> imap.multiappend("INBOX", [m1, m2])
Check they're there
> imap.examine("INBOX")
> uids = imap.uid_search(["ALL"])
> imap.uid_fetch(uids.last(2), ["BODY[]", "FLAGS"])
Development
After checking out the repo, run rake spec
to run the tests.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, update the version number in version.rb
,
and then run bundle exec rake release
, which will create a git tag for the version,
push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/joeyates/net-imap-multiappend. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Net::IMAP::Multiappend project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.