Browse files

Updated generating/sending email examples for Mail gem.

  • Loading branch information...
1 parent 5dfb079 commit 26484893b0293f5b03be895646cfde809f5d0ed4 dcparker committed May 14, 2010
Showing with 21 additions and 8 deletions.
  1. +21 −8 index.html
@@ -121,14 +121,27 @@
# Or "move" the message to a label
<h4>5) Create new emails!</h4>
-<code><pre>new_email = MIME::Message.generate ""
-new_email.subject "Having fun in Puerto Rico!"
-plain, html = new_email.generate_multipart('text/plain', 'text/html')
-plain.content = "Text of plaintext message."
-html.content = "&lt;p&gt;Text of &lt;em&gt;html&lt;/em&gt; message.&lt;/p&gt;"
+<p>Creating emails now uses the amazing <a href="">Mail</a> rubygem. See its <a href="">documentation here</a>. 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.</p>
+<code><pre>gmail.deliver do
+ to ""
+ subject "Having fun in Puerto Rico!"
+ text_part do
+ body "Text of plaintext message."
+ end
+ html_part do
+ body "&lt;p&gt;Text of &lt;em&gt;html&lt;/em&gt; message.&lt;/p&gt;"
+ end
+ add_file "/path/to/some_image.jpg"
+# Or, generate the message first and send it later
+email = gmail.generate_message do
+ to ""
+ subject "Having fun in Puerto Rico!"
+ body "Spent the day on the road..."
+# Or...

0 comments on commit 2648489

Please sign in to comment.