https://github.com/eval/uri-imap
IMAP URIs
https://github.com/eval/uri-imap
gem imap ruby rubygem uri
Last synced: 2 months ago
JSON representation
IMAP URIs
- Host: GitHub
- URL: https://github.com/eval/uri-imap
- Owner: eval
- License: mit
- Created: 2025-08-11T12:19:05.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-08-11T12:34:56.000Z (8 months ago)
- Last Synced: 2025-10-21T21:52:28.264Z (6 months ago)
- Topics: gem, imap, ruby, rubygem, uri
- Language: Ruby
- Homepage: https://eval.github.io/uri-imap/
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# URI::IMAP [](https://badge.fury.io/rb/uri-imap) [](https://eval.github.io/uri-imap/)
Extends Ruby's `URI` with support for IMAP-uri's.
## Installation
Install the gem and add to the application's Gemfile by executing:
```bash
bundle add uri-imap
```
If bundler is not being used to manage dependencies, install the gem by executing:
```bash
gem install uri-imap
```
## Usage
### parse
```ruby
u = URI("imaps+plain://user%40gmail.com:p%40ss@imap.gmail.com")
url.scheme #=> "imaps+plain"
url.auth #=> "plain"
url.starttls #=> false
url.starttls? #=> false
url.tls? #=> true
url.userinfo #=> "user%40gmail.com:p%40ss"
url.decoded_userinfo #=> "user@gmail.com:p@ss"
url.decoded_user #=> "user@gmail.com"
url.user #=> "user%40gmail.com"
url.decoded_password #=> "p@ss"
url.password #=> "p%40ss"
url.host #=> "imap.gmail.com"
url.port #=> 993
```
### to_h
```ruby
URI("imaps+login://user%40gmail.com:p%40ss@imap.gmail.com").to_h
#=>
{auth: "login",
host: "imap.gmail.com",
port: 993,
scheme: "imaps+login",
starttls: false,
tls: true,
user: "user@gmail.com",
password: "p@ss"}
```
## IMAP-URI
There's no official specification for IMAP-URIs. There's some prior work though. This implementation is heavily inspired by [aerc](https://git.sr.ht/~rjarry/aerc/tree/master/item/doc/aerc-imap.5.scd).
`[+]://[[:]@][:][?]`
### scheme
- `imap`
IMAP with STARTTLS (i.e. `url.starttls #=> :always`).
- `imap+insecure`
IMAP without STARTTLS (i.e. `url.starttls #=> false`)..
- `imaps`
IMAP with TLS.
### auth
Any value for auth that passes the URI-parser is acceptable. Though the following values have special meaning:
- `none`
No authentication is required.
- `plain`
Authenticate with a username and password using AUTH PLAIN. This is the default behavior when no authentication is provided.
> [!NOTE]
> any query's value for `auth` takes precedence.
### Examples
TBD
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Use `bin/yard server --reload` when working on documentation.
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](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/eval/uri-imap.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).