gmail 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +27 -27
  4. data/.rspec +1 -1
  5. data/.rubocop.yml +53 -13
  6. data/.rubocop_todo.yml +299 -239
  7. data/.travis.yml +19 -19
  8. data/CHANGELOG.md +152 -145
  9. data/Gemfile +5 -3
  10. data/LICENSE +21 -21
  11. data/README.md +380 -355
  12. data/Rakefile +44 -46
  13. data/gmail.gemspec +32 -34
  14. data/lib/gmail.rb +72 -78
  15. data/lib/gmail/client.rb +35 -34
  16. data/lib/gmail/client/base.rb +244 -229
  17. data/lib/gmail/client/plain.rb +24 -24
  18. data/lib/gmail/client/xoauth.rb +67 -68
  19. data/lib/gmail/client/xoauth2.rb +39 -39
  20. data/lib/gmail/imap_extensions.rb +156 -159
  21. data/lib/gmail/labels.rb +80 -79
  22. data/lib/gmail/mailbox.rb +178 -175
  23. data/lib/gmail/message.rb +212 -207
  24. data/lib/gmail/version.rb +3 -3
  25. data/spec/account.yml.example +1 -1
  26. data/spec/account.yml.obfus +2 -2
  27. data/spec/gmail/client/base_spec.rb +5 -5
  28. data/spec/gmail/client/plain_spec.rb +169 -169
  29. data/spec/gmail/client/xoauth2_spec.rb +186 -186
  30. data/spec/gmail/client/xoauth_spec.rb +5 -5
  31. data/spec/gmail/client_spec.rb +5 -5
  32. data/spec/gmail/imap_extensions_spec.rb +47 -47
  33. data/spec/gmail/labels_spec.rb +27 -27
  34. data/spec/gmail/mailbox_spec.rb +84 -84
  35. data/spec/gmail/message_spec.rb +181 -181
  36. data/spec/gmail_spec.rb +40 -39
  37. data/spec/recordings/gmail/_new_connects_with_client_and_give_it_context_when_block_given.yml +61 -28
  38. data/spec/recordings/gmail/_new_connects_with_gmail_service_and_return_valid_connection_object.yml +43 -28
  39. data/spec/recordings/gmail/_new_does_not_raise_error_when_couldn_t_connect_with_given_account.yml +21 -13
  40. data/spec/recordings/gmail/_new_raises_error_when_couldn_t_connect_with_given_account.yml +21 -13
  41. data/spec/recordings/gmail_client_plain/instance/delivers_inline_composed_email.yml +61 -42
  42. data/spec/recordings/gmail_client_plain/instance/does_not_log_in_when_given_gmail_account_is_invalid.yml +21 -13
  43. data/spec/recordings/gmail_client_plain/instance/does_not_raise_error_even_though_gmail_account_is_invalid.yml +21 -13
  44. data/spec/recordings/gmail_client_plain/instance/labels/checks_if_there_is_given_label_defined.yml +409 -196
  45. data/spec/recordings/gmail_client_plain/instance/labels/creates_given_label.yml +280 -151
  46. data/spec/recordings/gmail_client_plain/instance/labels/removes_existing_label.yml +271 -146
  47. data/spec/recordings/gmail_client_plain/instance/labels/returns_list_of_all_available_labels.yml +227 -113
  48. data/spec/recordings/gmail_client_plain/instance/properly_logs_in_to_valid_gmail_account.yml +61 -42
  49. data/spec/recordings/gmail_client_plain/instance/properly_logs_out_from_gmail.yml +61 -42
  50. data/spec/recordings/gmail_client_plain/instance/properly_switches_to_given_mailbox.yml +164 -109
  51. data/spec/recordings/gmail_client_plain/instance/properly_switches_to_given_mailbox_using_block_style.yml +164 -109
  52. data/spec/recordings/gmail_client_plain/instance/raises_error_when_given_gmail_account_is_invalid_and_errors_enabled.yml +21 -13
  53. data/spec/recordings/gmail_client_xo_auth2/instance/does_not_log_in_when_given_gmail_account_is_invalid.yml +24 -13
  54. data/spec/recordings/gmail_client_xo_auth2/instance/labels/checks_if_there_is_given_label_defined.yml +39 -27
  55. data/spec/recordings/gmail_client_xo_auth2/instance/labels/creates_given_label.yml +52 -39
  56. data/spec/recordings/gmail_client_xo_auth2/instance/labels/removes_existing_label.yml +52 -39
  57. data/spec/recordings/gmail_client_xo_auth2/instance/labels/returns_list_of_all_available_labels.yml +39 -27
  58. data/spec/recordings/gmail_client_xo_auth2/instance/properly_logs_in_to_valid_gmail_account.yml +26 -15
  59. data/spec/recordings/gmail_client_xo_auth2/instance/properly_logs_out_from_gmail.yml +26 -15
  60. data/spec/recordings/gmail_client_xo_auth2/instance/properly_switches_to_given_mailbox.yml +63 -40
  61. data/spec/recordings/gmail_client_xo_auth2/instance/properly_switches_to_given_mailbox_using_block_style.yml +63 -40
  62. data/spec/recordings/gmail_client_xo_auth2/instance/raises_error_when_given_gmail_account_is_invalid_and_errors_enabled.yml +24 -13
  63. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/all/localizes_into_the_appropriate_label.yml +229 -116
  64. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/and_the_mailbox_does_not_exist/returns_the_mailbox_name_as_a_string.yml +229 -110
  65. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/drafts/localizes_into_the_appropriate_label.yml +229 -116
  66. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/flagged/localizes_into_the_appropriate_label.yml +229 -116
  67. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/important/localizes_into_the_appropriate_label.yml +229 -116
  68. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/inbox/localizes_into_the_appropriate_label.yml +61 -42
  69. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/junk/localizes_into_the_appropriate_label.yml +229 -116
  70. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/sent/localizes_into_the_appropriate_label.yml +229 -116
  71. data/spec/recordings/gmail_labels/localize/when_given_the_xl_is_tflag/trash/localizes_into_the_appropriate_label.yml +229 -116
  72. data/spec/recordings/gmail_mailbox/instance/counts_all_emails.yml +595 -277
  73. data/spec/recordings/gmail_mailbox/instance/finds_messages.yml +1049 -586
  74. data/spec/recordings/gmail_mailbox/instance/waits_once.yml +191 -136
  75. data/spec/recordings/gmail_mailbox/instance/waits_repeatedly.yml +217 -141
  76. data/spec/recordings/gmail_mailbox/instance/waits_with_29-minute_re-issue.yml +188 -136
  77. data/spec/recordings/gmail_mailbox/instance/waits_with_an_unblocked_connection.yml +644 -207
  78. data/spec/recordings/gmail_mailbox/on_initialize/sets_client_and_name.yml +61 -42
  79. data/spec/recordings/gmail_mailbox/on_initialize/works_in_inbox_by_default.yml +61 -42
  80. data/spec/recordings/gmail_message/initialize/sets_prefetch_attrs.yml +1068 -578
  81. data/spec/recordings/gmail_message/initialize/sets_uid_and_mailbox.yml +1068 -580
  82. data/spec/recordings/gmail_message/instance_methods/deletes_itself.yml +1084 -637
  83. data/spec/recordings/gmail_message/instance_methods/marks_itself_read.yml +1137 -682
  84. data/spec/recordings/gmail_message/instance_methods/marks_itself_unread.yml +1153 -686
  85. data/spec/recordings/gmail_message/instance_methods/moves_from_one_tag_to_other.yml +1447 -862
  86. data/spec/recordings/gmail_message/instance_methods/removes_a_given_label.yml +1288 -776
  87. data/spec/recordings/gmail_message/instance_methods/removes_a_given_label_with_old_method.yml +1288 -776
  88. data/spec/recordings/gmail_message/instance_methods/sets_given_label.yml +1165 -690
  89. data/spec/recordings/gmail_message/instance_methods/sets_given_label_with_old_method.yml +1157 -691
  90. data/spec/spec_helper.rb +56 -53
  91. data/spec/support/imap_mock.rb +181 -181
  92. data/spec/support/obfuscation.rb +49 -52
  93. metadata +21 -90
  94. data/spec/recordings/gmail_client_plain/instance/_connection_automatically_logs_in_to_gmail_account_when_it_s_called.yml +0 -42
@@ -1,19 +1,19 @@
1
- rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.5
5
- - 2.2.0
6
- - rbx
7
- - jruby
8
-
9
- matrix:
10
- allow_failures:
11
- - rvm: rbx
12
- - rvm: jruby
13
-
14
- # http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
15
- sudo: false
16
-
17
- # script:
18
- # - bundle exec rspec
19
- # - bundle exec rubocop
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.5
5
+ - 2.2.0
6
+ - rbx
7
+ - jruby
8
+
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: rbx
12
+ - rvm: jruby
13
+
14
+ # http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
15
+ sudo: false
16
+
17
+ script:
18
+ - bundle exec rspec
19
+ - bundle exec rubocop -D
@@ -1,145 +1,152 @@
1
- # Gmail Gem Changelog
2
-
3
- ## Unreleased
4
-
5
- * Your change here
6
-
7
- ## 0.6.0 - 2015-8-24
8
-
9
- * [Fix: Labels#localize to not return nil (@afn)](https://github.com/gmailgem/gmail/pull/176)
10
- * [Fix: label parsing (@yn)](https://github.com/gmailgem/gmail/pull/179)
11
- * [Feature: Add IDLE support (@alexeymorozov)](https://github.com/gmailgem/gmail/pull/167)
12
- * [Fix: #deliver to always invoke compose (@kuboon)](https://github.com/gmailgem/gmail/pull/163)
13
-
14
- ## 0.5.0 - 2015-01-26
15
-
16
- * Migrate primary repo to https://github.com/gmailgem/gmail with new project governance (@johnnyshields, @bootstraponline)
17
- * Create logo for project (@johnnyshields)
18
- * Implement IMAP recorder for specs and get all specs passing (@jcarbo)
19
- * Add Rubocop to porject and fix offenses (@jcarbo)
20
- * Fix: #connect method not invoking a block (@jcarbo)
21
- * Support X-GM-RAW (raw Gmail search syntax) in filter query (@bootstraponline)
22
- * Bugfix: Improperly processing labels containing parentheses (@ryanlchan #82)
23
- * Add support for localizing labels (@ryanlchan #83)
24
- * Support for XOAuth2 Client (@KieranP)
25
- * Improve support for non-english labels and mailboxes (@KieranP)
26
- * Fix IMAP library patch on Ruby 2 (@bootstraponline, @johnnyshields, @awakia)
27
- * Ability to search emails by a UID filter (@KieranP)
28
- * Add a way to disconnect the IMAP socket (@KieranP)
29
- * Better support for timezones (@KieranP)
30
- * Add `emails_in_batches` method (@KieranP)
31
- * Gmail Message class: Include X-GM-THRID which is the thread id (@jcarbo)
32
- * Gmail Message class: Include X-GM-MSGID which is a unique, non-changing email identifier (@KieranP)
33
- * Gmail Message class: Fetch values in bulk and cache them (performance) (@KieranP)
34
- * Gmail Message class: Pull FLAGS to make #read? and #starred? methods work (@KieranP)
35
- * Gmail Message class: Don't mark an email as read when accessing the message (@KieranP)
36
- * Gmail Message class: Reorganisation and cleanup of method definitions (@KieranP)
37
- * Bugfix: Fix for XOAuth SMTP settings (@molsder #24)
38
- * Implement Travis CI (@johnnyshields)
39
- * Remove legacy dependency on MIME gem (@johnnyshields)
40
- * Upgrade to RSpec 3.1 and remove Mocha dependency (@johnnyshields, @jcarbo #156)
41
-
42
-
43
- ## 0.4.2
44
-
45
- * Fix issue related to Mail gem version lock (@johnnyshields)
46
-
47
-
48
- ## 0.4.1
49
-
50
- * n/a
51
-
52
-
53
- ## 0.4.0
54
-
55
- * Added XOAuth authentication method (Stefano Bernardi, Nicolas Fouché)
56
- * Separated clients
57
- * Fixed specs
58
-
59
-
60
- ## 0.3.4
61
-
62
- * Fixes in mailbox filters shortcuts (Benjamin Bock)
63
-
64
-
65
- ## 0.3.3
66
-
67
- * Added #expunge to Mailbox (Benjamin Bock)
68
- * Added more mailbox filters (Benjamin Bock)
69
- * Added shortcuts for mailbox filters
70
- * Minor bugfixes
71
-
72
-
73
- ## 0.3.2
74
-
75
- * Added envelope fetching
76
- * Minor bugfixes
77
-
78
-
79
- ## 0.3.0
80
-
81
- * Refactoring
82
- * Fixed bugs
83
- * API improvements
84
- * Better documentation
85
- * Code cleanup
86
- * RSpec for everything
87
-
88
-
89
- ## 0.1.1 - 2010-05-11
90
-
91
- * Added explicit tmail dependency in gemspec
92
- * Added better README tutorial content
93
-
94
-
95
- ## 0.0.9 - 2010-04-17
96
-
97
- * Fixed content-transfer-encoding when sending email
98
-
99
-
100
- ## 0.0.8 - 2009-12-23
101
-
102
- * Fixed attaching a file to an empty message
103
-
104
-
105
- ## 0.0.7 - 2009-12-23
106
-
107
- * Improved multipart message parsing reliability
108
-
109
-
110
- ## 0.0.6 - 2009-12-21
111
-
112
- * Fixed multipart parsing for when the boundary is marked in quotes.
113
-
114
-
115
- ## 0.0.5 - 2009-12-16
116
-
117
- * Fixed IMAP initializer to work with Ruby 1.9's net/imap
118
- * Better logout depending on the IMAP connection itself
119
- * Added MIME::Message#text and MIME::Message#html for easier access to an email body
120
- * Improved the MIME-parsing API slightly
121
- * Added some tests
122
-
123
-
124
- ## 0.0.4 - 2009-11-30
125
-
126
- * Added label creation (@justinperkins)
127
- * Made the gem login automatically when first needed
128
- * Added an optional block on the Gmail.new object that will login and logout for you
129
- * Added several search options (@mikker)
130
-
131
-
132
- ## 0.0.3 - 2009-11-19
133
-
134
- * Fixed MIME::Message#content= for messages without an encoding
135
- * Added Gmail#new_message
136
-
137
-
138
- ## 0.0.2 - 2009-11-18
139
-
140
- * Made all of the examples in the README possible
141
-
142
-
143
- ## 0.0.1 - 2009-11-18
144
-
145
- * Birthday!
1
+ # Gmail Gem Changelog
2
+
3
+ ## 0.7.0 - 2018-07-19
4
+
5
+ * Add coveralls.io code coverage (@bootstraponline)
6
+ * Fixes and clarifications to Readme (@kitlangton, @asiniy, @amoludage, @joshsoftware, @JoeNyland)
7
+ * Add message_id to search params (#242) (@unkrich)
8
+ * Add xoauth2 example to readme (#211) (@markgandolfo)
9
+ * Fix Rubocop (@bootstraponline, @RustyNail)
10
+ * Improve speed of archiving methods (#234) (@github0013)
11
+ * Exclude 'gmail' when attempting to display a message as_json (#259) (@lcpriest)
12
+ * Remove Object monkey patch and use Net::IMAP.format_date (#260) (@tcaddy)
13
+
14
+ ## 0.6.0 - 2015-08-24
15
+
16
+ * Fix: Labels#localize to not return nil ([@afn](https://github.com/@afn), [#176](https://github.com/gmailgem/gmail/pull/176))
17
+ * Fix: label parsing ([@yn](https://github.com/@yn), [#179](https://github.com/gmailgem/gmail/pull/179))
18
+ * Feature: Add IDLE support([@alexeymorozov](https://github.com/@alexeymorozov), [#167](https://github.com/gmailgem/gmail/pull/167))
19
+ * Fix: #deliver to always invoke compose ([@kuboon](https://github.com/@kuboon), [#163](https://github.com/gmailgem/gmail/pull/163))
20
+
21
+ ## 0.5.0 - 2015-01-26
22
+
23
+ * Migrate primary repo to https://github.com/gmailgem/gmail with new project governance (@johnnyshields, @bootstraponline)
24
+ * Create logo for project (@johnnyshields)
25
+ * Implement IMAP recorder for specs and get all specs passing (@jcarbo)
26
+ * Add Rubocop to porject and fix offenses (@jcarbo)
27
+ * Fix: #connect method not invoking a block (@jcarbo)
28
+ * Support X-GM-RAW (raw Gmail search syntax) in filter query (@bootstraponline)
29
+ * Bugfix: Improperly processing labels containing parentheses (@ryanlchan #82)
30
+ * Add support for localizing labels (@ryanlchan #83)
31
+ * Support for XOAuth2 Client (@KieranP)
32
+ * Improve support for non-english labels and mailboxes (@KieranP)
33
+ * Fix IMAP library patch on Ruby 2 (@bootstraponline, @johnnyshields, @awakia)
34
+ * Ability to search emails by a UID filter (@KieranP)
35
+ * Add a way to disconnect the IMAP socket (@KieranP)
36
+ * Better support for timezones (@KieranP)
37
+ * Add `emails_in_batches` method (@KieranP)
38
+ * Gmail Message class: Include X-GM-THRID which is the thread id (@jcarbo)
39
+ * Gmail Message class: Include X-GM-MSGID which is a unique, non-changing email identifier (@KieranP)
40
+ * Gmail Message class: Fetch values in bulk and cache them (performance) (@KieranP)
41
+ * Gmail Message class: Pull FLAGS to make #read? and #starred? methods work (@KieranP)
42
+ * Gmail Message class: Don't mark an email as read when accessing the message (@KieranP)
43
+ * Gmail Message class: Reorganisation and cleanup of method definitions (@KieranP)
44
+ * Bugfix: Fix for XOAuth SMTP settings (@molsder #24)
45
+ * Implement Travis CI (@johnnyshields)
46
+ * Remove legacy dependency on MIME gem (@johnnyshields)
47
+ * Upgrade to RSpec 3.1 and remove Mocha dependency (@johnnyshields, @jcarbo #156)
48
+
49
+
50
+ ## 0.4.2
51
+
52
+ * Fix issue related to Mail gem version lock (@johnnyshields)
53
+
54
+
55
+ ## 0.4.1
56
+
57
+ * n/a
58
+
59
+
60
+ ## 0.4.0
61
+
62
+ * Added XOAuth authentication method (Stefano Bernardi, Nicolas Fouché)
63
+ * Separated clients
64
+ * Fixed specs
65
+
66
+
67
+ ## 0.3.4
68
+
69
+ * Fixes in mailbox filters shortcuts (Benjamin Bock)
70
+
71
+
72
+ ## 0.3.3
73
+
74
+ * Added #expunge to Mailbox (Benjamin Bock)
75
+ * Added more mailbox filters (Benjamin Bock)
76
+ * Added shortcuts for mailbox filters
77
+ * Minor bugfixes
78
+
79
+
80
+ ## 0.3.2
81
+
82
+ * Added envelope fetching
83
+ * Minor bugfixes
84
+
85
+
86
+ ## 0.3.0
87
+
88
+ * Refactoring
89
+ * Fixed bugs
90
+ * API improvements
91
+ * Better documentation
92
+ * Code cleanup
93
+ * RSpec for everything
94
+
95
+
96
+ ## 0.1.1 - 2010-05-11
97
+
98
+ * Added explicit tmail dependency in gemspec
99
+ * Added better README tutorial content
100
+
101
+
102
+ ## 0.0.9 - 2010-04-17
103
+
104
+ * Fixed content-transfer-encoding when sending email
105
+
106
+
107
+ ## 0.0.8 - 2009-12-23
108
+
109
+ * Fixed attaching a file to an empty message
110
+
111
+
112
+ ## 0.0.7 - 2009-12-23
113
+
114
+ * Improved multipart message parsing reliability
115
+
116
+
117
+ ## 0.0.6 - 2009-12-21
118
+
119
+ * Fixed multipart parsing for when the boundary is marked in quotes.
120
+
121
+
122
+ ## 0.0.5 - 2009-12-16
123
+
124
+ * Fixed IMAP initializer to work with Ruby 1.9's net/imap
125
+ * Better logout depending on the IMAP connection itself
126
+ * Added MIME::Message#text and MIME::Message#html for easier access to an email body
127
+ * Improved the MIME-parsing API slightly
128
+ * Added some tests
129
+
130
+
131
+ ## 0.0.4 - 2009-11-30
132
+
133
+ * Added label creation (@justinperkins)
134
+ * Made the gem login automatically when first needed
135
+ * Added an optional block on the Gmail.new object that will login and logout for you
136
+ * Added several search options (@mikker)
137
+
138
+
139
+ ## 0.0.3 - 2009-11-19
140
+
141
+ * Fixed MIME::Message#content= for messages without an encoding
142
+ * Added Gmail#new_message
143
+
144
+
145
+ ## 0.0.2 - 2009-11-18
146
+
147
+ * Made all of the examples in the README possible
148
+
149
+
150
+ ## 0.0.1 - 2009-11-18
151
+
152
+ * Birthday!
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "http://rubygems.org"
2
-
3
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'coveralls', :require => false
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
2
- Copyright (c) 2009-2010 BehindLogic
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyrignt (c) 2010 Kriss 'nu7hatch' Kowalik
2
+ Copyright (c) 2009-2010 BehindLogic
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,355 +1,380 @@
1
- <img alt="Gmail for Ruby" src="https://cloud.githubusercontent.com/assets/27655/5792399/fd5d076e-9f59-11e4-826c-22c311e38356.png">
2
-
3
- [![Build Status](https://travis-ci.org/gmailgem/gmail.svg)](https://travis-ci.org/gmailgem/gmail)
4
- [![Code Climate](https://codeclimate.com/github/gmailgem/gmail.svg)](https://codeclimate.com/github/gmailgem/gmail)
5
- [![Gem Version](https://badge.fury.io/rb/gmail.svg)](http://badge.fury.io/rb/gmail)
6
-
7
- A Rubyesque interface to Google's Gmail, with all the tools you'll need. Search,
8
- read and send multipart emails, archive, mark as read/unread, delete emails,
9
- and manage labels.
10
-
11
- It's based on Daniel Parker's ruby-gmail gem. This version has more friendly
12
- API, is well tested, better documented and have many other improvements.
13
-
14
- ## Installation
15
-
16
- You can install it easy using rubygems:
17
-
18
- sudo gem install gmail
19
-
20
- Or install it manually:
21
-
22
- git clone git://github.com/gmailgem/gmail.git
23
- cd gmail
24
- rake install
25
-
26
- gmail gem has the following dependencies (with Bundler all will be installed automatically):
27
-
28
- * mail
29
- * gmail_xoauth
30
-
31
- ## Version Support
32
-
33
- * Ruby 2.0.0+ is supported
34
- * Ruby 1.9.3 is supported but deprecated and is planned to be dropped from gmail v0.6.0
35
- * Ruby 1.8.7 users should use gmail v0.4.1
36
-
37
- ## Features
38
-
39
- * Search emails
40
- * Read emails (handles attachments)
41
- * Emails: label, archive, delete, mark as read/unread/spam, star
42
- * Manage labels
43
- * Create and send multipart email messages in plaintext and/or html, with inline
44
- images and attachments
45
- * Utilizes Gmail's IMAP & SMTP, MIME-type detection and parses and generates
46
- MIME properly.
47
-
48
- ## Basic usage
49
-
50
- First of all require the `gmail` library.
51
-
52
- ```ruby
53
- require 'gmail'
54
- ```
55
-
56
- ### Authenticating gmail sessions
57
-
58
- This will let you automatically log in to your account.
59
-
60
- ```ruby
61
- gmail = Gmail.connect(username, password)
62
- # play with your gmail...
63
- gmail.logout
64
- ```
65
-
66
- If you pass a block, the session will be passed into the block, and the session
67
- will be logged out after the block is executed.
68
-
69
- ```ruby
70
- Gmail.connect(username, password) do |gmail|
71
- # play with your gmail...
72
- end
73
- ```
74
-
75
- Examples above are "quiet", it means that it will not raise any errors when
76
- session couldn't be started (eg. because of connection error or invalid
77
- authorization data). You can use connection which handles errors raising:
78
-
79
- ```ruby
80
- Gmail.connect!(username, password)
81
- Gmail.connect!(username, password) {|gmail| ... play with gmail ... }
82
- ```
83
-
84
- You can also check if you are logged in at any time:
85
-
86
- ```ruby
87
- Gmail.connect(username, password) do |gmail|
88
- gmail.logged_in?
89
- end
90
- ```
91
-
92
- ### XOAuth authentication
93
-
94
- From v0.4.0 it's possible to authenticate with your Gmail account using XOAuth
95
- method. It's very simple:
96
-
97
- ```ruby
98
- gmail = Gmail.connect(:xoauth, "email@domain.com",
99
- :token => 'TOKEN',
100
- :secret => 'TOKEN_SECRET',
101
- :consumer_key => 'CONSUMER_KEY',
102
- :consumer_secret => 'CONSUMER_SECRET'
103
- )
104
- ```
105
-
106
- For more information check out the [gmail_xoauth](https://github.com/nfo/gmail_xoauth)
107
- gem from Nicolas Fouché.
108
-
109
- ### Counting and gathering emails
110
-
111
- Get counts for messages in the inbox:
112
-
113
- ```ruby
114
- gmail.inbox.count
115
- gmail.inbox.count(:unread)
116
- gmail.inbox.count(:read)
117
- ```
118
-
119
- Count with some criteria:
120
-
121
- ```ruby
122
- gmail.inbox.count(:after => Date.parse("2010-02-20"), :before => Date.parse("2010-03-20"))
123
- gmail.inbox.count(:on => Date.parse("2010-04-15"))
124
- gmail.inbox.count(:from => "myfriend@gmail.com")
125
- gmail.inbox.count(:to => "directlytome@gmail.com")
126
- ```
127
-
128
- Combine flags and options:
129
-
130
- ```ruby
131
- gmail.inbox.count(:unread, :from => "myboss@gmail.com")
132
- ```
133
-
134
- Browsing labeled emails is similar to work with inbox.
135
-
136
- ```ruby
137
- gmail.mailbox('Urgent').count
138
- ```
139
-
140
- Getting messages works the same way as counting: Remember that every message in a
141
- conversation/thread will come as a separate message.
142
-
143
- ```ruby
144
- gmail.inbox.emails(:unread, :before => Date.parse("2010-04-20"), :from => "myboss@gmail.com")
145
- ```
146
-
147
- The [gm option](https://developers.google.com/gmail/imap_extensions?csw=1#extension_of_the_search_command_x-gm-raw) enables use of the Gmail search syntax.
148
-
149
- ```ruby
150
- gmail.inbox.emails(gm: '"testing"')
151
- ```
152
-
153
- You can use also one of aliases:
154
-
155
- ```ruby
156
- gmail.inbox.find(...)
157
- gmail.inbox.search(...)
158
- gmail.inbox.mails(...)
159
- ```
160
-
161
- Also you can manipulate each message using block style:
162
-
163
- ```ruby
164
- gmail.inbox.find(:unread).each do |email|
165
- email.read!
166
- end
167
- ```
168
-
169
- ### Working with emails!
170
-
171
- Any news older than 4-20, mark as read and archive it:
172
-
173
- ```ruby
174
- gmail.inbox.find(:before => Date.parse("2010-04-20"), :from => "news@nbcnews.com").each do |email|
175
- email.read! # can also unread!, spam! or star!
176
- email.archive!
177
- end
178
- ```
179
-
180
- Delete emails from X:
181
-
182
- ```ruby
183
- gmail.inbox.find(:from => "x-fiance@gmail.com").each do |email|
184
- email.delete!
185
- end
186
- ```
187
-
188
- Save all attachments in the "Faxes" label to a local folder (uses functionality from `Mail` gem):
189
-
190
- ```ruby
191
- folder = Dir.pwd # for example
192
- gmail.mailbox("Faxes").emails.each do |email|
193
- email.message.attachments.each do |f|
194
- File.write(File.join(folder, f.filename), f.body.decoded)
195
- end
196
- end
197
- ```
198
-
199
- You can use also `#label` method instead of `#mailbox`:
200
-
201
- ```ruby
202
- gmail.label("Faxes").emails {|email| ... }
203
- ```
204
-
205
- Save just the first attachment from the newest unread email (assuming pdf):
206
-
207
- ```ruby
208
- email = gmail.inbox.find(:unread).first
209
- email.attachments[0].save_to_file("/path/to/location")
210
- ```
211
-
212
- Add a label to a message:
213
-
214
- ```ruby
215
- email.label("Faxes")
216
- ```
217
-
218
- Example above will raise error when you don't have the `Faxes` label. You can
219
- avoid this using:
220
-
221
- ```ruby
222
- email.label!("Faxes") # The `Faxes` label will be automatically created now
223
- ```
224
-
225
- You can also move message to a label/mailbox:
226
-
227
- ```ruby
228
- email.move_to("Faxes")
229
- email.move_to!("NewLabel")
230
- ```
231
-
232
- There is also few shortcuts to mark messages quickly:
233
-
234
- ```ruby
235
- email.read!
236
- email.unread!
237
- email.spam!
238
- email.star!
239
- email.unstar!
240
- ```
241
-
242
- ### Managing labels
243
-
244
- With Gmail gem you can also manage your labels. You can get list of defined
245
- labels:
246
-
247
- ```ruby
248
- gmail.labels.all
249
- ```
250
-
251
- Create new label:
252
-
253
- ```ruby
254
- gmail.labels.new("Urgent")
255
- gmail.labels.add("AnotherOne")
256
- ```
257
-
258
- Remove labels:
259
-
260
- ```ruby
261
- gmail.labels.delete("Urgent")
262
- ```
263
-
264
- Or check if given label exists:
265
-
266
- ```ruby
267
- gmail.labels.exists?("Urgent") # => false
268
- gmail.labels.exists?("AnotherOne") # => true
269
- ```
270
-
271
- Localize label names using the LIST special-use extension flags,
272
- :Inbox, :All, :Drafts, :Sent, :Trash, :Important, :Junk, and :Flagged
273
-
274
- ```ruby
275
- gmail.labels.localize(:all) # => "[Gmail]\All Mail"
276
- # => "[Google Mail]\All Mail"
277
- ```
278
-
279
- ### Composing and sending emails
280
-
281
- Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubygem.
282
- See its [documentation here](http://github.com/mikel/mail). The Ruby Gmail will
283
- automatically configure your Mail emails to be sent via your Gmail account's SMTP,
284
- so they will be in your Gmail's "Sent" folder. Also, no need to specify the "From"
285
- email either, because ruby-gmail will set it for you.
286
-
287
- ```ruby
288
- gmail.deliver do
289
- to "email@example.com"
290
- subject "Having fun in Puerto Rico!"
291
- text_part do
292
- body "Text of plaintext message."
293
- end
294
- html_part do
295
- content_type 'text/html; charset=UTF-8'
296
- body "<p>Text of <em>html</em> message.</p>"
297
- end
298
- add_file "/path/to/some_image.jpg"
299
- end
300
- ```
301
-
302
- Or, compose the message first and send it later
303
-
304
- ```ruby
305
- email = gmail.compose do
306
- to "email@example.com"
307
- subject "Having fun in Puerto Rico!"
308
- body "Spent the day on the road..."
309
- end
310
- email.deliver! # or: gmail.deliver(email)
311
- ```
312
-
313
- ## Troubleshooting
314
-
315
- If you are having trouble connecting to Gmail:
316
- * Please ensure your account is verified
317
- * In [Gmail Security Settings](https://www.google.com/settings/security), enable access for less secure applications.
318
- * Read [this support answer re: suspicious activity](https://support.google.com/mail/answer/78754) and try things like entering a captcha.
319
-
320
- ## Note on Patches/Pull Requests
321
-
322
- * Fork the project.
323
- * Make your feature addition or bug fix.
324
- * Add tests for it. This is important so I don't break it in a
325
- future version unintentionally.
326
- * Commit, do not mess with rakefile, version, or history.
327
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
328
- * Send me a pull request. Bonus points for topic branches.
329
-
330
- ## Authors
331
-
332
- #### Core Team
333
-
334
- This project follows on Open Governance model. The Core Team is responsible for technical guidance, reviewing/merging PRs, and releases.
335
-
336
- * Jeff Carbonella - [@jcarbo](https://github.com/jcarbo)
337
- * Johnny Shields - [@johnnyshields](https://github.com/johnnyshields)
338
- * Alexandre Loureiro Solleiro - [@webcracy](https://github.com/webcracy)
339
- * Justin Grevich - [@jgrevich](https://github.com/jgrevich)
340
- * [@bootstraponline](https://github.com/bootstraponline)
341
- * Nathan Herald - [@myobie](https://github.com/myobie)
342
-
343
- #### Legacy Contributors
344
-
345
- * Kriss Kowalik - [@nu7hatch](https://github.com/nu7hatch)
346
- * Daniel Parker - [@dcparker](https://github.com/dcparker)
347
- * Refer to [CHANGELOG](https://github.com/gmailgem/gmail/blob/master/CHANGELOG.md) for individual contributions
348
-
349
- ## Copyright
350
-
351
- * Copyright (c) 2015 GmailGem team
352
- * Copyright (c) 2010-2014 Kriss 'nu7hatch' Kowalik
353
- * Copyright (c) 2009-2010 BehindLogic
354
-
355
- Licensed under the MIT license. See [LICENSE](https://github.com/gmailgem/gmail/blob/master/LICENSE) for details.
1
+ <img alt="Gmail for Ruby" src="https://cloud.githubusercontent.com/assets/27655/5792399/fd5d076e-9f59-11e4-826c-22c311e38356.png">
2
+
3
+ [![Build Status](https://travis-ci.org/gmailgem/gmail.svg)](https://travis-ci.org/gmailgem/gmail)
4
+ [![Code Climate](https://codeclimate.com/github/gmailgem/gmail.svg)](https://codeclimate.com/github/gmailgem/gmail)
5
+ [![Gem Version](https://badge.fury.io/rb/gmail.svg)](https://rubygems.org/gems/gmail)
6
+ [![Coverage Status](https://coveralls.io/repos/gmailgem/gmail/badge.svg?branch=master&service=github&nocache=true)](https://coveralls.io/github/gmailgem/gmail?branch=master)
7
+
8
+ ## Deprecation Notice
9
+
10
+ As of version 0.7.0 (Aug 19, 2018) this gem is officially deprecated and will no longer be maintained.
11
+ Please instead use [Google's official Gmail API Ruby Client](https://developers.google.com/gmail/api/quickstart/ruby),
12
+ which uses the Gmail API rather than IMAP and has significantly better performance and reliability.
13
+
14
+ ## Overview
15
+
16
+ This gem is a Rubyesque interface to Google's Gmail via IMAP. Search, read and send multipart emails,
17
+ archive, mark as read/unread, delete emails, and manage labels. It's based on [Daniel Parker's ruby-gmail gem](https://github.com/dcparker/ruby-gmail).
18
+
19
+ ## Reporting Issues
20
+
21
+ As of version 0.7.x, we are accepting pull requests for critical security patches only.
22
+
23
+ This gem uses the [Mail gem](https://github.com/mikel/mail) for messages, attachments, etc. Unless your issue is related to Gmail integration specifically, please refer to [RFC-5322 (email specification)](https://tools.ietf.org/html/rfc5322) and the [Mail gem](https://github.com/mikel/mail).
24
+
25
+ ## Installation
26
+
27
+ You can install it easy using rubygems:
28
+
29
+ sudo gem install gmail
30
+
31
+ Or install it manually:
32
+
33
+ git clone git://github.com/gmailgem/gmail.git
34
+ cd gmail
35
+ rake install
36
+
37
+ gmail gem has the following dependencies (with Bundler all will be installed automatically):
38
+
39
+ * mail
40
+ * gmail_xoauth
41
+
42
+ ## Version Support
43
+
44
+ * Ruby 2.0.0+ is supported.
45
+ * Ruby 1.9.3 is supported but deprecated.
46
+ * Ruby 1.8.7 users should use gmail v0.4.1
47
+
48
+ ## Features
49
+
50
+ * Search emails
51
+ * Read emails (handles attachments)
52
+ * Emails: label, archive, delete, mark as read/unread/spam, star
53
+ * Manage labels
54
+ * Create and send multipart email messages in plaintext and/or html, with inline
55
+ images and attachments
56
+ * Utilizes Gmail's IMAP & SMTP, MIME-type detection and parses and generates
57
+ MIME properly.
58
+
59
+ ## Basic usage
60
+
61
+ First of all require the `gmail` library.
62
+
63
+ ```ruby
64
+ require 'gmail'
65
+ ```
66
+
67
+ ### Authenticating gmail sessions
68
+
69
+ This will let you automatically log in to your account.
70
+
71
+ ```ruby
72
+ gmail = Gmail.connect(username, password)
73
+ # play with your gmail...
74
+ gmail.logout
75
+ ```
76
+
77
+ If you pass a block, the session will be passed into the block, and the session
78
+ will be logged out after the block is executed.
79
+
80
+ ```ruby
81
+ Gmail.connect(username, password) do |gmail|
82
+ # play with your gmail...
83
+ end
84
+ ```
85
+
86
+ Examples above are "quiet", it means that it will not raise any errors when
87
+ session couldn't be started (eg. because of connection error or invalid
88
+ authorization data). You can use connection which handles errors raising:
89
+
90
+ ```ruby
91
+ Gmail.connect!(username, password)
92
+ Gmail.connect!(username, password) {|gmail| ... play with gmail ... }
93
+ ```
94
+
95
+ You can also check if you are logged in at any time:
96
+
97
+ ```ruby
98
+ Gmail.connect(username, password) do |gmail|
99
+ gmail.logged_in?
100
+ end
101
+ ```
102
+
103
+ ### XOAuth authentication
104
+
105
+ From v0.4.0 it's possible to authenticate with your Gmail account using XOAuth
106
+ method. It's very simple:
107
+
108
+ ```ruby
109
+ gmail = Gmail.connect(:xoauth, "email@domain.com",
110
+ :token => 'TOKEN',
111
+ :secret => 'TOKEN_SECRET',
112
+ :consumer_key => 'CONSUMER_KEY',
113
+ :consumer_secret => 'CONSUMER_SECRET'
114
+ )
115
+ ```
116
+
117
+ ```ruby
118
+ gmail = Gmail.connect(:xoauth2, 'email@domain.com', 'ACCESS_TOKEN')
119
+ ```
120
+
121
+ For more information check out the [gmail_xoauth](https://github.com/nfo/gmail_xoauth)
122
+ gem from Nicolas Fouché.
123
+
124
+ ### XOAuth2 authentication
125
+
126
+ You can use the oauth2 token to connect to Gmail. The connect method takes 3 paramaters.
127
+
128
+ ```ruby
129
+ gmail = Gmail.connect(:xoauth2, "email@domain.com", "TOKEN")
130
+ ```
131
+ You can use [omniauth-google-oauth2](https://github.com/zquestz/omniauth-google-oauth2) to fetch the token. Once the omniauth authorization has been completed, you'll be left with a `auth.credentials.token` you can pass in as the third paramater to `Gmail.connect`.
132
+
133
+ ### Counting and gathering emails
134
+
135
+ Get counts for messages in the inbox:
136
+
137
+ ```ruby
138
+ gmail.inbox.count
139
+ gmail.inbox.count(:unread)
140
+ gmail.inbox.count(:read)
141
+ ```
142
+
143
+ Count with some criteria:
144
+
145
+ ```ruby
146
+ gmail.inbox.count(:after => Date.parse("2010-02-20"), :before => Date.parse("2010-03-20"))
147
+ gmail.inbox.count(:on => Date.parse("2010-04-15"))
148
+ gmail.inbox.count(:from => "myfriend@gmail.com")
149
+ gmail.inbox.count(:to => "directlytome@gmail.com")
150
+ ```
151
+
152
+ Combine flags and options:
153
+
154
+ ```ruby
155
+ gmail.inbox.count(:unread, :from => "myboss@gmail.com")
156
+ ```
157
+
158
+ Browsing labeled emails is similar to work with inbox.
159
+
160
+ ```ruby
161
+ gmail.mailbox('Urgent').count
162
+ ```
163
+
164
+ Getting messages works the same way as counting: Remember that every message in a
165
+ conversation/thread will come as a separate message.
166
+
167
+ ```ruby
168
+ gmail.inbox.emails(:unread, :before => Date.parse("2010-04-20"), :from => "myboss@gmail.com")
169
+ ```
170
+
171
+ The [gm option](https://developers.google.com/gmail/imap_extensions?csw=1#extension_of_the_search_command_x-gm-raw) enables use of the Gmail search syntax.
172
+
173
+ ```ruby
174
+ gmail.inbox.emails(gm: '"testing"')
175
+ ```
176
+
177
+ You can also use one of aliases:
178
+
179
+ ```ruby
180
+ gmail.inbox.find(...)
181
+ gmail.inbox.search(...)
182
+ gmail.inbox.mails(...)
183
+ ```
184
+
185
+ Also you can manipulate each message using block style:
186
+
187
+ ```ruby
188
+ gmail.inbox.find(:unread).each do |email|
189
+ email.read!
190
+ end
191
+ ```
192
+
193
+ Note: The `:before` and `:after` filters only go as far as to search for messages on the date:
194
+
195
+ ```ruby
196
+ # E.g. the following will return messages between 2016-01-01 00:00:00 and 2016-04-05 00:00:00
197
+ gmail.inbox.find(
198
+ :after => Time.parse('2016-01-01 07:50:21'),
199
+ :before => Time.parse('2016-04-05 21:55:05')
200
+ )
201
+ ```
202
+
203
+ ### Working with emails!
204
+
205
+ Any news older than 4-20, mark as read and archive it:
206
+
207
+ ```ruby
208
+ gmail.inbox.find(:before => Date.parse("2010-04-20"), :from => "news@nbcnews.com").each do |email|
209
+ email.read! # can also unread!, spam! or star!
210
+ email.archive!
211
+ end
212
+ ```
213
+
214
+ Delete emails from X:
215
+
216
+ ```ruby
217
+ gmail.inbox.find(:from => "x-fiance@gmail.com").each do |email|
218
+ email.delete!
219
+ end
220
+ ```
221
+
222
+ Save all attachments from the "Faxes" label to a local folder (uses functionality from `Mail` gem):
223
+
224
+ ```ruby
225
+ folder = Dir.pwd # for example
226
+ gmail.mailbox("Faxes").emails.each do |email|
227
+ email.message.attachments.each do |f|
228
+ File.write(File.join(folder, f.filename), f.body.decoded)
229
+ end
230
+ end
231
+ ```
232
+
233
+ You can also use `#label` method instead of `#mailbox`:
234
+
235
+ ```ruby
236
+ gmail.label("Faxes").emails.each {|email| ... }
237
+ ```
238
+
239
+ Save just the first attachment from the newest unread email (assuming pdf):
240
+
241
+ ```ruby
242
+ email = gmail.inbox.find(:unread).first
243
+ attachment = email.attachments[0]
244
+ File.write(File.join(folder_path, attachment.filename), attachment.body.decoded)
245
+ ```
246
+
247
+ Add a label to a message:
248
+
249
+ ```ruby
250
+ email.label("Faxes")
251
+ ```
252
+
253
+ Example above will raise error when you don't have the `Faxes` label. You can
254
+ avoid this using:
255
+
256
+ ```ruby
257
+ email.label!("Faxes") # The `Faxes` label will be automatically created now
258
+ ```
259
+
260
+ You can also move message to a label/mailbox:
261
+
262
+ ```ruby
263
+ email.move_to("Faxes")
264
+ email.move_to!("NewLabel")
265
+ ```
266
+
267
+ There are also few shortcuts to mark messages quickly:
268
+
269
+ ```ruby
270
+ email.read!
271
+ email.unread!
272
+ email.spam!
273
+ email.star!
274
+ email.unstar!
275
+ ```
276
+
277
+ ### Managing labels
278
+
279
+ With Gmail gem you can also manage your labels. You can get list of defined
280
+ labels:
281
+
282
+ ```ruby
283
+ gmail.labels.all
284
+ ```
285
+
286
+ Create new label:
287
+
288
+ ```ruby
289
+ gmail.labels.new("Urgent")
290
+ gmail.labels.add("AnotherOne")
291
+ ```
292
+
293
+ Remove labels:
294
+
295
+ ```ruby
296
+ gmail.labels.delete("Urgent")
297
+ ```
298
+
299
+ Or check if given label exists:
300
+
301
+ ```ruby
302
+ gmail.labels.exists?("Urgent") # => false
303
+ gmail.labels.exists?("AnotherOne") # => true
304
+ ```
305
+
306
+ Localize label names using the LIST special-use extension flags,
307
+ :Inbox, :All, :Drafts, :Sent, :Trash, :Important, :Junk, and :Flagged
308
+
309
+ ```ruby
310
+ gmail.labels.localize(:all) # => "[Gmail]\All Mail"
311
+ # => "[Google Mail]\All Mail"
312
+ ```
313
+
314
+ ### Composing and sending emails
315
+
316
+ Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubygem.
317
+ See its [documentation here](http://github.com/mikel/mail). The Ruby Gmail will
318
+ automatically configure your Mail emails to be sent via your Gmail account's SMTP,
319
+ so they will be in your Gmail's "Sent" folder. Also, no need to specify the "From"
320
+ email either, because ruby-gmail will set it for you.
321
+
322
+ ```ruby
323
+ gmail.deliver do
324
+ to "email@example.com"
325
+ subject "Having fun in Puerto Rico!"
326
+ text_part do
327
+ body "Text of plaintext message."
328
+ end
329
+ html_part do
330
+ content_type 'text/html; charset=UTF-8'
331
+ body "<p>Text of <em>html</em> message.</p>"
332
+ end
333
+ add_file "/path/to/some_image.jpg"
334
+ end
335
+ ```
336
+
337
+ Or, compose the message first and send it later
338
+
339
+ ```ruby
340
+ email = gmail.compose do
341
+ to "email@example.com"
342
+ subject "Having fun in Puerto Rico!"
343
+ body "Spent the day on the road..."
344
+ end
345
+ email.deliver! # or: gmail.deliver(email)
346
+ ```
347
+
348
+ ## Troubleshooting
349
+
350
+ If you are having trouble connecting to Gmail:
351
+ * Please ensure your account is verified
352
+ * In [Gmail Security Settings](https://www.google.com/settings/security), enable access for less secure applications.
353
+ * Read [this support answer re: suspicious activity](https://support.google.com/mail/answer/78754) and try things like entering a captcha.
354
+
355
+ ## Authors
356
+
357
+ #### Core Team
358
+
359
+ This project follows on Open Governance model. The Core Team is responsible for technical guidance, reviewing/merging PRs, and releases.
360
+
361
+ * Jeff Carbonella - [@jcarbo](https://github.com/jcarbo)
362
+ * Johnny Shields - [@johnnyshields](https://github.com/johnnyshields)
363
+ * Alexandre Loureiro Solleiro - [@webcracy](https://github.com/webcracy)
364
+ * Justin Grevich - [@jgrevich](https://github.com/jgrevich)
365
+ * [@bootstraponline](https://github.com/bootstraponline)
366
+ * Nathan Herald - [@myobie](https://github.com/myobie)
367
+
368
+ #### Legacy Contributors
369
+
370
+ * Kriss Kowalik - [@nu7hatch](https://github.com/nu7hatch)
371
+ * Daniel Parker - [@dcparker](https://github.com/dcparker)
372
+ * Refer to [CHANGELOG](https://github.com/gmailgem/gmail/blob/master/CHANGELOG.md) for individual contributions
373
+
374
+ ## Copyright
375
+
376
+ * Copyright (c) 2015-2018 GmailGem team
377
+ * Copyright (c) 2010-2014 Kriss 'nu7hatch' Kowalik
378
+ * Copyright (c) 2009-2010 BehindLogic
379
+
380
+ Licensed under the MIT license. See [LICENSE](https://github.com/gmailgem/gmail/blob/master/LICENSE) for details.