You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubygem. See its [documentation here](http://github.com/mikel/mail). Ruby-gmail will automatically configure your Mail emails to be sent via your Gmail account's SMTP, so they will be in your Gmail's "Sent" folder. Also, no need to specify the "From" email either, because ruby-gmail will set it for you.
119
131
120
-
gmail.deliver do
121
-
to "email@example.com"
122
-
subject "Having fun in Puerto Rico!"
123
-
text_part do
124
-
body "Text of plaintext message."
125
-
end
126
-
html_part do
127
-
content_type 'text/html; charset=UTF-8'
128
-
body "<p>Text of <em>html</em> message.</p>"
129
-
end
130
-
add_file "/path/to/some_image.jpg"
131
-
end
132
-
# Or, generate the message first and send it later
133
-
email = gmail.generate_message do
134
-
to "email@example.com"
135
-
subject "Having fun in Puerto Rico!"
136
-
body "Spent the day on the road..."
137
-
end
138
-
email.deliver!
139
-
# Or...
140
-
gmail.deliver(email)
132
+
```ruby
133
+
gmail.deliver do
134
+
to "email@example.com"
135
+
subject "Having fun in Puerto Rico!"
136
+
text_part do
137
+
body "Text of plaintext message."
138
+
end
139
+
html_part do
140
+
content_type 'text/html; charset=UTF-8'
141
+
body "<p>Text of <em>html</em> message.</p>"
142
+
end
143
+
add_file "/path/to/some_image.jpg"
144
+
end
145
+
# Or, generate the message first and send it later
146
+
email = gmail.generate_message do
147
+
to "email@example.com"
148
+
subject "Having fun in Puerto Rico!"
149
+
body "Spent the day on the road..."
150
+
end
151
+
email.deliver!
152
+
# Or...
153
+
gmail.deliver(email)
154
+
```
141
155
142
156
## Requirements
143
157
@@ -149,7 +163,9 @@ Creating emails now uses the amazing [Mail](http://rubygems.org/gems/mail) rubyg
0 commit comments