Sending Gmail with Mail Gem.

July 18, 2012 — 1 Comment
require 'rubygems'
require 'mail'

# Set up delivery defaults to use Gmail
Mail.defaults do
  delivery_method :smtp, { 
    :address => '',
    :port => '587',
    :user_name => '<user>',
    :password => '<password>',
    :authentication => :plain,
    :enable_starttls_auto => true

# Send email with attachment.
mail = do
  from     '<user>'
  to       '[email protected]'
  subject  'Hi, Michael Le'
  #add_file :filename => 'hello_world.txt', 
:content =>'hello_world.txt')


# Don't forget delivery

You can check Mikel Lindsaar’s mail gem on github.


Posts Twitter Facebook

My name is Michael Le, and I am a web developer.

One response to Sending Gmail with Mail Gem.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.