<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,10 +8,31 @@ A simple gem to send email through gmail
   g = GmailSender.new(&quot;gmail_account_user_name&quot;, &quot;gmail_account_password&quot;)
   g.send(&quot;someone@domain.com&quot;, &quot;The subject&quot;, &quot;The mail body&quot;)
 
+== Command line usage
+
+You can also use gmail_sender from the command line. First you need to create ~/.gmail with this content (YAML):
+
+  receiver_email: default_receiver@gmail.com
+  sender_user: gmail_account_user_name
+  sender_password: gmail_account_password
+
+Is advisable to use a different sender account than your main email address so that it's not so bad if someone reads your configuration file and gets your password.
+
+=== Examples
+
+To send your directory list to the default receiver:
+
+  ls | gmail
+
+You can specify some parameters like in this example which doesn't use pipes:
+
+  gmail -t somebody@gmail.com -s &quot;This is the subject&quot; -c &quot;This is the email content&quot; 
+  
 == Requirements
 
 tlsmail if running Ruby 1.8.6
 
-== Copyright
+== Major contributors
 
-Copyright (c) 2009 Daniel Cadenas. See LICENSE for details.
+* Daniel Cadenas - Maintainer
+* Felipe Coury</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,5 @@
 #!/usr/bin/env ruby
 
-$: &lt;&lt; File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;lib&quot;)
-
 require 'rubygems'
 require 'gmail_sender'
 require 'choice'
@@ -10,13 +8,13 @@ Choice.options do
   header ''
   header 'options:'
   
-  option :to, :required =&gt; true do
+  option :receiver_email do
     short '-t'
     long '--to=RECEIVER'
     desc 'Receiver of the email'
   end
 
-  option :subject, :required =&gt; true do
+  option :subject do
     short '-s'
     long '--subject=SUBJECT'
     desc 'Subject of the email'
@@ -25,28 +23,29 @@ Choice.options do
   option :content do
     short '-c'
     long '--content=MAIL_CONTENTS'
-    desc 'Body of the email, uses STDIN of omitted'
+    desc 'Body of the email, uses STDIN if omitted'
   end
 end
 
-def read_config
-  config = {}
-  group = nil
-  File.foreach(&quot;#{ENV['HOME']}/.gmail&quot;) do |line|
-    line.strip!
-    if line[0] != ?# and line =~ /\S/
-      if line =~ /^\[(.*)\]$/
-        group = $1
-      else
-        key, value = line.split(&quot;=&quot;)
-        value ||= ''
-        (config[group]||={})[key.strip] = value.strip
-      end
-    end
+def params
+  return @params if @params
+
+  config_file_path = File.join(ENV['HOME'],'.gmail')
+  if !File.exists?(config_file_path)
+    STDERR.puts &quot;Please first create a ~/.gmail file with some defaults. Example:
+      receiver_email: default_receiver@gmail.com
+      sender_user: gmail_account_user_name
+      sender_password: gmail_account_user_password
+    &quot;
+    exit 1
   end
-  config
+
+  defaults = {'subject' =&gt; 'Sent from command line',
+              'sender_domain' =&gt; 'gmail.com'}
+
+  @params = defaults.merge(YAML.load_file(config_file_path)).merge(Choice.choices)
 end
 
-config = read_config['account']
-mailer = Gmail::Emailer.new(config['user'], config['password'], config['domain'])
-mailer.send(Choice.choices[:to], Choice.choices[:subject], Choice.choices[:content] || STDIN.read)
\ No newline at end of file
+
+mailer = GmailSender.new(params['sender_user'], params['sender_password'], params['sender_domain'])
+mailer.send(params['receiver_email'], params['subject'], params['content'] || STDIN.read)</diff>
      <filename>bin/gmail</filename>
    </modified>
    <modified>
      <diff>@@ -8,10 +8,11 @@ Gem::Specification.new do |s|
   s.authors = [&quot;Daniel Cadenas&quot;, &quot;Felipe Coury&quot;]
   s.date = %q{2009-05-25}
   s.email = %q{dcadenas@gmail.com felipe.coury@gmail.com}
+  s.bindir = &quot;bin&quot;
   s.executables = [&quot;gmail&quot;]
   s.extra_rdoc_files = [
     &quot;LICENSE&quot;,
-     &quot;README.rdoc&quot;
+    &quot;README.rdoc&quot;
   ]
   s.files = [
     &quot;.document&quot;,
@@ -31,7 +32,7 @@ Gem::Specification.new do |s|
   s.rdoc_options = [&quot;--charset=UTF-8&quot;]
   s.require_paths = [&quot;lib&quot;]
   s.rubygems_version = %q{1.3.3}
-  s.summary = %q{A simple gem to send email through gmail}
+  s.summary = s.description = %q{A simple gem to send email through gmail}
   s.test_files = [
     &quot;test/gmail_sender_test.rb&quot;,
      &quot;test/test_helper.rb&quot;</diff>
      <filename>gmail_sender.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -1,30 +1,28 @@
 require &quot;tls_smtp_patch&quot;
 
-module Gmail
-  class Emailer
-    def initialize(user, password, domain=&quot;gmail.com&quot;)
-      @domain   = domain
-      @password = password
-      @user     = &quot;#{user}@#{domain}&quot;
-      @net_smtp = Net::SMTP.new(&quot;smtp.gmail.com&quot;, 587)
-      @net_smtp.enable_starttls 
-    end
+class GmailSender
+  def initialize(user, password, domain=&quot;gmail.com&quot;)
+    @sender_domain   = domain
+    @sender_password = password
+    @sender_email     = &quot;#{user}@#{domain}&quot;
+    @net_smtp = Net::SMTP.new(&quot;smtp.gmail.com&quot;, 587)
+    @net_smtp.enable_starttls 
+  end
 
-    def send(to, subject, content)
-      @net_smtp.start(@domain, @user, @password, :plain) do |smtp|
-        msg = create_message(to, subject, content)
-        smtp.send_message(msg, @user, to)
-      end
+  def send(to, subject, content)
+    @net_smtp.start(@sender_domain, @sender_email, @sender_password, :plain) do |smtp|
+      msg = create_message(to, subject, content)
+      smtp.send_message(msg, @sender_email, to)
     end
+  end
 
-    def create_message(to, subject, content)
+  def create_message(to, subject, content)
 &lt;&lt;MSG
-From: #@gmail_user
+From: #@sender_email
 To: #{to}
 Subject: #{subject}
 
 #{content}
 MSG
-    end
   end
 end</diff>
      <filename>lib/gmail_sender.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,6 @@
 require 'rubygems'
 require 'expectations'
 
-
 $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
 $LOAD_PATH.unshift(File.dirname(__FILE__))
 require 'gmail_sender'
-
-class Test::Unit::TestCase
-end</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>53bcf06eb96adac0981d003df1f5dff789f20e9c</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Cadenas</name>
    <email>dcadenas@gmail.com</email>
  </author>
  <url>http://github.com/dcadenas/gmail_sender/commit/119fdcf53bee205974a01495c18947d9a3c54523</url>
  <id>119fdcf53bee205974a01495c18947d9a3c54523</id>
  <committed-date>2009-11-01T18:55:50-08:00</committed-date>
  <authored-date>2009-11-01T14:26:21-08:00</authored-date>
  <message>Added command line functionality (thanks fcuory!)</message>
  <tree>2e0ee9cbba1719c84653846831ea6a68cb1a7087</tree>
  <committer>
    <name>Daniel Cadenas</name>
    <email>dcadenas@gmail.com</email>
  </committer>
</commit>
