hi
any good examples how to set up email (sendmail especially) with ruby
on rails.
I have tried several examples from the net but no success.
I tried these instructions:
http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer
and what I have now in controller
def generic_email(options)
@sent_on = options[:sent_on] || Time.now
@recipients = options[:recipients] ||
"my.email-gJ1G9MGqaQg@public.gmane.org"
@from = options[:from] || "Me
<my.email-gJ1G9MGqaQg@public.gmane.org>"
@cc = options[:cc] || ""
@bcc = options[:bcc] || ""
@subject = options[:subject] || "Test Email"
@body = options[:body] || {}
@headers = options[:headers] || {}
@charset = options[:charset] || "utf-8"
end
def test
options=Hash.new
self.generic_email(options)
end
when I run test http://localhost:3000/test
nothing happens ... no email ... cant see anything on the log etc
on environment.rb file i have
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.perform_deliveries = true
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 14 Feb 2008, at 00:06, KTU wrote:> > hi > > any good examples how to set up email (sendmail especially) with ruby > on rails. >Is your sendmail where rails expects it to be (usr/sbin/sendmail)? You can of course override this setting, but that is where it will look by default. Also, in order for an email to actually be send you need to call SomeMailer.deliver_generic_email (or create_generic_email and then send that). Lastly it sounds like you''ve defined generic_email on your controller, which obviously can''t work. It needs to be defined on a subclass of ActionMailer::Base (script/generate mailer will generate you the right files) Fred> I have tried several examples from the net but no success. > > I tried these instructions: > > http://wiki.rubyonrails.org/rails/pages/ > HowToSendEmailsWithActionMailer > > and what I have now in controller > > def generic_email(options) > > @sent_on = options[:sent_on] || Time.now > @recipients = options[:recipients] || "my.email-gJ1G9MGqaQg@public.gmane.org" > @from = options[:from] || "Me <my.email-gJ1G9MGqaQg@public.gmane.org>" > @cc = options[:cc] || "" > @bcc = options[:bcc] || "" > @subject = options[:subject] || "Test Email" > @body = options[:body] || {} > @headers = options[:headers] || {} > @charset = options[:charset] || "utf-8" > end > > def test > options=Hash.new > self.generic_email(options) > end > > when I run test http://localhost:3000/test > > nothing happens ... no email ... cant see anything on the log etc > > on environment.rb file i have > > ActionMailer::Base.delivery_method = :sendmail > ActionMailer::Base.perform_deliveries = true > > > > > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > For more options, visit this group at http://gr--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
what i have is this:
Controller
======
def generic_email(options)
@sent_on = options[:sent_on] || Time.now
@recipients = options[:recipients] ||
"my.em...-gJ1G9MGqaQg@public.gmane.org"
@from = options[:from] || "Me
<my.em...-gJ1G9MGqaQg@public.gmane.org>"
@cc = options[:cc] || ""
@bcc = options[:bcc] || ""
@subject = options[:subject] || "Test Email"
@body = options[:body] || {}
@headers = options[:headers] || {}
@charset = options[:charset] || "utf-8"
UserMailer.deliver_signup_thanks()
redirect_to :action => ''main''
end
def test
options=Hash.new
self.generic_email(options)
end
now I try to run URL this http://localhost:3000/test ie. test should
make that Hash and call self.generic_emai
which calls UserMailer.deliver_signup_thanks() and this file is on my
models directory notifier.rb and it has this:
def signup_thanks()
# Email header info MUST be added here
recipients "my.email-gJ1G9MGqaQg@public.gmane.org"
from "my.email-gJ1G9MGqaQg@public.gmane.org"
subject "Test 123"
# Email body substitutions go here
# body :user=> user
body "test123"
end
So I just try to send pre-defined email to myself but it does not seem
to work. Yes sendmail is in /usr/sbin directory.
Strange is that I cant see any logs or anything...
when I run http://localhost:3000/test
i see only this page but nothing goes to server logs and I dont see
any email logs anywhere ...
NameError in ImitemsController#test
uninitialized constant ImitemsController::UserMailer
RAILS_ROOT: /usr/local/webhome/mdm
Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
active_support/dependencies.rb:478:in `const_missing''
app/controllers/imitems_controller.rb:16:in `generic_email''
app/controllers/imitems_controller.rb:22:in `test''
On Feb 14, 3:50 am, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 14 Feb 2008, at 00:06, KTU wrote:
>
>
>
> > hi
>
> > any good examples how to set up email (sendmail especially) with ruby
> > on rails.
>
> Is your sendmail where rails expects it to be (usr/sbin/sendmail)? You
> can of course override this setting, but that is where it will look by
> default.
> Also, in order for an email to actually be send you need to call
> SomeMailer.deliver_generic_email (or create_generic_email and then
> send that).
> Lastly it sounds like you''ve defined generic_email on your
controller,
> which obviously can''t work. It needs to be defined on a subclass
of
> ActionMailer::Base (script/generate mailer will generate you the right
> files)
>
> Fred
>
> > I have tried several examples from the net but no success.
>
> > I tried these instructions:
>
> >http://wiki.rubyonrails.org/rails/pages/
> > HowToSendEmailsWithActionMailer
>
> > and what I have now in controller
>
> > def generic_email(options)
>
> > @sent_on = options[:sent_on] || Time.now
> > @recipients = options[:recipients] ||
"my.em...-gJ1G9MGqaQg@public.gmane.org"
> > @from = options[:from] || "Me
<my.em...-gJ1G9MGqaQg@public.gmane.org>"
> > @cc = options[:cc] || ""
> > @bcc = options[:bcc] || ""
> > @subject = options[:subject] || "Test Email"
> > @body = options[:body] || {}
> > @headers = options[:headers] || {}
> > @charset = options[:charset] || "utf-8"
> > end
>
> > def test
> > options=Hash.new
> > self.generic_email(options)
> > end
>
> > when I run testhttp://localhost:3000/test
>
> > nothing happens ... no email ... cant see anything on the log etc
>
> > on environment.rb file i have
>
> > ActionMailer::Base.delivery_method = :sendmail
> > ActionMailer::Base.perform_deliveries = true
>
> > --~--~---------~--~----~------------~-------~--~----~
> > You received this message because you are subscribed to the Google
> > Groups "Ruby on Rails: Talk" group.
> > To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > For more options, visit this group athttp://gr
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
i got it to work i needed to add these on config/environments/
development.rb
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
:location => ''/usr/sbin/sendmail'',
:arguments => ''-i -t''
}
#ActionMailer::Base.template_root = "mailer/templates"
# mailer will look for rhtml templates in that path
# example: "mailer/templates/my_mailer/signup_mail.rhtml"
ActionMailer::Base.perform_deliveries = true # the "deliver_*" methods
are available
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.default_content_type = "text/html" # default:
"text/
plain"
ActionMailer::Base.default_mime_version = "1.0"
ActionMailer::Base.default_implicit_parts_order = [ "text/html",
"text/
plain"]
and config/environment.rb these
ActionMailer::Base.delivery_method = :sendmail
#ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
On Feb 14, 10:09 am, KTU
<ketuo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> what i have is this:
>
> Controller
> ======>
> def generic_email(options)
>
> @sent_on = options[:sent_on] || Time.now
> @recipients = options[:recipients] ||
"my.em...-gJ1G9MGqaQg@public.gmane.org"
> @from = options[:from] || "Me
<my.em...-gJ1G9MGqaQg@public.gmane.org>"
> @cc = options[:cc] || ""
> @bcc = options[:bcc] || ""
> @subject = options[:subject] || "Test Email"
> @body = options[:body] || {}
> @headers = options[:headers] || {}
> @charset = options[:charset] || "utf-8"
> UserMailer.deliver_signup_thanks()
> redirect_to :action => ''main''
>
> end
>
> def test
> options=Hash.new
> self.generic_email(options)
> end
>
> now I try to run URL thishttp://localhost:3000/testie. test should
> make that Hash and call self.generic_emai
> which calls UserMailer.deliver_signup_thanks() and this file is on my
> models directory notifier.rb and it has this:
>
> def signup_thanks()
> # Email header info MUST be added here
> recipients "my.em...-gJ1G9MGqaQg@public.gmane.org"
> from "my.em...-gJ1G9MGqaQg@public.gmane.org"
> subject "Test 123"
>
> # Email body substitutions go here
> # body :user=> user
> body "test123"
> end
>
> So I just try to send pre-defined email to myself but it does not seem
> to work. Yes sendmail is in /usr/sbin directory.
>
> Strange is that I cant see any logs or anything...
>
> when I runhttp://localhost:3000/test
>
> i see only this page but nothing goes to server logs and I dont see
> any email logs anywhere ...
>
> NameError in ImitemsController#test
>
> uninitialized constant ImitemsController::UserMailer
>
> RAILS_ROOT: /usr/local/webhome/mdm
> Application Trace | Framework Trace | Full Trace
>
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/
> active_support/dependencies.rb:478:in `const_missing''
> app/controllers/imitems_controller.rb:16:in `generic_email''
> app/controllers/imitems_controller.rb:22:in `test''
>
> On Feb 14, 3:50 am, Frederick Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>
> > On 14 Feb 2008, at 00:06, KTU wrote:
>
> > > hi
>
> > > any good examples how to set up email (sendmail especially) with
ruby
> > > on rails.
>
> > Is your sendmail where rails expects it to be (usr/sbin/sendmail)? You
> > can of course override this setting, but that is where it will look by
> > default.
> > Also, in order for an email to actually be send you need to call
> > SomeMailer.deliver_generic_email (or create_generic_email and then
> > send that).
> > Lastly it sounds like you''ve defined generic_email on your
controller,
> > which obviously can''t work. It needs to be defined on a
subclass of
> > ActionMailer::Base (script/generate mailer will generate you the right
> > files)
>
> > Fred
>
> > > I have tried several examples from the net but no success.
>
> > > I tried these instructions:
>
> > >http://wiki.rubyonrails.org/rails/pages/
> > > HowToSendEmailsWithActionMailer
>
> > > and what I have now in controller
>
> > > def generic_email(options)
>
> > > @sent_on = options[:sent_on] || Time.now
> > > @recipients = options[:recipients] ||
"my.em...-gJ1G9MGqaQg@public.gmane.org"
> > > @from = options[:from] || "Me
<my.em...-gJ1G9MGqaQg@public.gmane.org>"
> > > @cc = options[:cc] || ""
> > > @bcc = options[:bcc] || ""
> > > @subject = options[:subject] || "Test Email"
> > > @body = options[:body] || {}
> > > @headers = options[:headers] || {}
> > > @charset = options[:charset] || "utf-8"
> > > end
>
> > > def test
> > > options=Hash.new
> > > self.generic_email(options)
> > > end
>
> > > when I run testhttp://localhost:3000/test
>
> > > nothing happens ... no email ... cant see anything on the log etc
>
> > > on environment.rb file i have
>
> > > ActionMailer::Base.delivery_method = :sendmail
> > > ActionMailer::Base.perform_deliveries = true
>
> > > --~--~---------~--~----~------------~-------~--~----~
> > > You received this message because you are subscribed to the
Google
> > > Groups "Ruby on Rails: Talk" group.
> > > To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
> > > For more options, visit this group athttp://gr
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---