Method: Gmail::Client::Base#compose

Defined in:
lib/gmail/client/base.rb

#compose(mail = nil, &block) ⇒ Object Also known as: message

Compose new e-mail.

Examples

mail = gmail.compose
mail.from "[email protected]"
mail.to "[email protected]"

… or block style:

mail = gmail.compose do 
  from "[email protected]"
  to "[email protected]"
  subject "Hello!"
  body "Hello my friend! long time..."
end

Now you can deliver your mail:

gmail.deliver(mail)


98
99
100
101
102
103
104
105
106
107
108
# File 'lib/gmail/client/base.rb', line 98

def compose(mail=nil, &block)
  if block_given?
    mail = Mail.new(&block)
  elsif !mail 
    mail = Mail.new
  end 

  mail.delivery_method(*smtp_settings)
  mail.from = username unless mail.from
  mail
end