easymailer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in easymailer.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 harish
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Easymailer
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'easymailer'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install easymailer
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,41 @@
1
+ Description
2
+
3
+ Easymailer gem is used to create demo mailer application instantly.This gem is usefull for those who creating a mailer applications from scratch.This will automatically generate ActionMailer scripts and files.This will also create a demo page for you to start simply sending mails in a smart and faster way.This is used in all Rails3.2 version applications and mainly usefull for rails startups which removes the headache of scripting stuff..
4
+
5
+ Installation
6
+
7
+ step1 :
8
+ gem install easymailer
9
+
10
+ step2 :
11
+ place (gem 'easymailer') in your gem file
12
+
13
+ step3 :
14
+ bundle install
15
+
16
+ step4:
17
+ initially in any controller place the Easymailer.create_mailer
18
+ example:
19
+
20
+ app/controllers/demo_controller.rb
21
+ class DemoController < ApplicationController
22
+ require 'easy_mailer'
23
+ def index
24
+ @message=EasyMailer.create_mailer
25
+ end
26
+ end
27
+
28
+ app/views/index.html.erb
29
+ <%=@message%>
30
+
31
+ if you get message as "Mailer created Sucessfully" Then Change the settings in config/initializers/setup_mail.rb
32
+ (for Gmail change username and password) which is created auomatically.
33
+ and restart your Application!
34
+
35
+ step5:
36
+ Go to link http://localhost:3000/email/send_email or YourIP/email/send_email
37
+
38
+
39
+
40
+
41
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'easymailer/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "easymailer"
8
+ gem.version = Easymailer::VERSION
9
+ gem.authors = ["harish"]
10
+ gem.email = ["bkholyharish@gmail.com"]
11
+ gem.description = %q{Easymailer gem is used to create demo mailer application instantly.This gem is very usefull for those who creating a mailer applications from scratch.This will automatically generate ActionMailer scripts and files.This will also create a demo page for you to start simply sending mails in a smart and faster way.This is used in all Rails3.2 version applications and very usefull for rails startups which removes the headache of scripting stuff.. }
12
+ gem.summary = %q{Easymailer gem is used to create demo mailer application instantly.This gem is very usefull for those who creating a mailer applications from scratch.This will automatically generate ActionMailer scripts and files.This will also create a demo page for you to start simply sending mails in a smart and faster way.This is used in all Rails3.2 version applications and very usefull for rails startups which removes the headache of scripting stuff..}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,166 @@
1
+ require "easymailer/version"
2
+
3
+ module Easymailer
4
+ def self.create_mailer
5
+ if File.file?( "#{Rails.root}/config/initializers/setup_mail.rb" )
6
+ return "Mailer exists..please the settings in config/initializers/setup_mail.rb and restart your application!"
7
+ else
8
+
9
+ File.open("#{Rails.root}/app/mailers/user_mailer.rb", 'w+') do |file|
10
+ file.syswrite(self.usermailer_text)
11
+ end
12
+
13
+ Dir.mkdir( "#{Rails.root}/app/views/user_mailer")
14
+ Dir.mkdir( "#{Rails.root}/tmp/uploads")
15
+ Dir.mkdir( "#{Rails.root}/app/views/email")
16
+
17
+ File.open("#{Rails.root}/app/views/user_mailer/send_mail.text.erb", 'w+') do |file|
18
+ file.syswrite("<%=@message%>")
19
+ end
20
+
21
+ File.open("#{Rails.root}/config/initializers/setup_mail.rb", 'w+') do |file|
22
+ file.syswrite(self.setup_mail)
23
+ end
24
+
25
+ File.open("#{Rails.root}/app/controllers/email_controller.rb", 'w+') do |file|
26
+ file.syswrite(self.email_controller)
27
+ end
28
+
29
+ File.open("#{Rails.root}/app/views/email/send_email.html.erb", 'w+') do |file|
30
+ file.syswrite(self.send_email_view)
31
+ end
32
+
33
+ at_line=3
34
+ File.open("#{Rails.root}/config/routes.rb",'r+') do |file|
35
+ while (at_line-=1) > 0 # read up to the line you want to write after
36
+ file.readline
37
+ end
38
+ pos = file.pos # save your position in the file
39
+ rest = file.read # save the rest of the file
40
+ file.seek pos # go back to the old position
41
+ file.write ["\n match 'email/send_email'=>'email#send_email' \n", rest] # write new data & rest of file
42
+ end
43
+ return "Mailer created Sucessfully.Change the settings in config/initializers/setup_mail.rb and restart your Application!"
44
+ end
45
+ end
46
+
47
+ def self.usermailer_text
48
+ @name='attachments["#{file_name}"] = File.read(path)'
49
+ "class UserMailer < ActionMailer::Base
50
+ default :from => 'eabyas.notifier@gmail.com'
51
+ def send_mail(message,email,subject,path,file_name)
52
+ @message=message
53
+ unless path.nil?
54
+ #{@name}
55
+ end
56
+ mail(:to => email,:subject => subject)
57
+ end
58
+ end"
59
+ end
60
+
61
+ def self.setup_mail
62
+ "ActionMailer::Base.smtp_settings = {
63
+ :address => 'smtp.gmail.com',
64
+ :port => 587,
65
+ :domain => 'gmail.com',
66
+ :user_name => 'notifier@gmail.com', #Your user name
67
+ :password => 'password', # Your password
68
+ :authentication => 'plain',
69
+ :enable_starttls_auto => true
70
+ }"
71
+ end
72
+
73
+ def self.email_controller
74
+ "class EmailController < ApplicationController
75
+ require 'easymailer'
76
+ def send_email
77
+ if request.post?
78
+ unless params[:email][:to].nil? or params[:email][:to].blank?
79
+ to_mail=params[:email][:to]
80
+ subject=params[:email][:subject]
81
+ message=params[:email][:message]
82
+ attachment=params[:email][:file]
83
+
84
+ unless attachment.nil? and attachment.blank?
85
+ file_name=attachment.original_filename
86
+ dir='/home/harish/september_12/Learning_Rails3/ocean_layout/tmp/uploads/'
87
+ path=File.join(dir,file_name)
88
+ File.open(path,'w+')
89
+ File.open(path, 'wb') { |f| f.write(attachment.read) }
90
+
91
+ Easymailer.send_mail(message,to_mail,subject,path,file_name).deliver
92
+ File.delete(path)
93
+ else
94
+ Easymailer.send_mail(message,to_mail,subject,nil,nil).deliver
95
+ end
96
+ flash[:notice]='Email Sent Sucesssfully'
97
+ else
98
+ flash[:notice]='Please enter Email Id..!'
99
+ end
100
+ end
101
+ end
102
+ end"
103
+ end
104
+
105
+ def self.send_email_view
106
+ "<%=form_for :email,:html => { :multipart => true } do |f|%>
107
+ <table>
108
+ <tr><th><h2>Send Email</h2></th></tr>
109
+ <tr><td>Mail To</td><td><%=f.text_field :to%></td></tr>
110
+ <tr><td>Subject</td><td><%=f.text_field :subject%></td></tr>
111
+ <tr><td>Message</td><td><%=f.text_area :message,:rows=>7,:cols=>40%></td></tr>
112
+ <tr><td>Attachment</td><td><%=f.file_field :file%></td></tr>
113
+ <tr><td colspan='2'><%=f.submit 'Send email'%></td></tr>
114
+ </table>
115
+ <%end%>
116
+ <div id='flash' style='display:none;'>Sending Mail Please Wait..</div>
117
+ <%unless flash[:notice].nil?%>
118
+ <div class='notice'><p><%=flash[:notice]%><%flash[:notice]=nil%></p></div>
119
+ <%end%>
120
+
121
+ <style type='text/css'>
122
+ #flash{
123
+ background:#ECC3C3;font-size:14px;
124
+ border: 1px solid #A9A9A9;
125
+ text-align:center;
126
+ width:800px;
127
+ margin:0px auto;
128
+ }
129
+ .notice{background:#99FF99;font-size:14px;
130
+ border: 1px solid #A9A9A9;
131
+ text-align:center;
132
+ width:800px;
133
+ margin:0px auto;
134
+ }
135
+ </style>
136
+
137
+ <script type='text/javascript'>
138
+ $(document).ready(function(){
139
+ $('form').submit(function(){
140
+ $('#flash').css('display','block');
141
+ $('.notice').css('display','none');
142
+ });
143
+ });
144
+ </script>"
145
+ end
146
+
147
+ def self.send_mail(message,email,subject,path,file_name)
148
+ if File.file?( "#{Rails.root}/config/initializers/setup_mail.rb" )
149
+ UserMailer.send_mail(message,email,subject,path,file_name).deliver
150
+ else
151
+ self.create_mailer
152
+ end
153
+ end
154
+
155
+ def self.mail_settings(address,port,domain,username,password)
156
+ ActionMailer::Base.smtp_settings = {
157
+ :address => address,
158
+ :port => port,
159
+ :domain => domain,
160
+ :user_name => username, #Your user name
161
+ :password => password, # Your password
162
+ :authentication => 'plain',
163
+ :enable_starttls_auto => true
164
+ }
165
+ end
166
+ end
@@ -0,0 +1,3 @@
1
+ module Easymailer
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: easymailer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - harish
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-10-03 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: "Easymailer gem is used to create demo mailer application instantly.This gem is very usefull for those who creating a mailer applications from scratch.This will automatically generate ActionMailer scripts and files.This will also create a demo page for you to start simply sending mails in a smart and faster way.This is used in all Rails3.2 version applications and very usefull for rails startups which removes the headache of scripting stuff.. "
22
+ email:
23
+ - bkholyharish@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE.txt
34
+ - README.md
35
+ - README.txt
36
+ - Rakefile
37
+ - easymailer.gemspec
38
+ - lib/easymailer.rb
39
+ - lib/easymailer/version.rb
40
+ homepage: ""
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.24
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Easymailer gem is used to create demo mailer application instantly.This gem is very usefull for those who creating a mailer applications from scratch.This will automatically generate ActionMailer scripts and files.This will also create a demo page for you to start simply sending mails in a smart and faster way.This is used in all Rails3.2 version applications and very usefull for rails startups which removes the headache of scripting stuff..
73
+ test_files: []
74
+
75
+ has_rdoc: