ruby - ActionMailer 3 without Rails -


i'm writing small ruby program pull records database , send html email daily. i'm attempting use actionmailer 3.0.3 this, i'm running in issues. searching i've done far on using actionmailer outside of rails applies versions prior version 3. point me in right direction of find resources on how this? here's far on mailer file:

# lib/bug_mailer.rb require 'action_mailer'  actionmailer::base.delivery_method = :file  class bugmailer < actionmailer::base   def daily_email     mail(             :to      => "example@mail.com",             :from    => "example@mail.com",             :subject => "testing mail"     )   end end  bugmailer.daily_email.deliver 

i'm stuck on put views. every attempt i've made tell actionmailer templates has failed.

i guess should ask if there's different way go accomplishing program. basically, i'm doing scratch @ point. makes rails awesome it's convention, trying use parts of rails on own waste of time? there way rails-like environment without creating full-blown rails app?

after serious debugging, found how configure it.

file mailer.rb

require 'action_mailer'  actionmailer::base.raise_delivery_errors = true actionmailer::base.delivery_method = :smtp actionmailer::base.smtp_settings = {    :address   => "smtp.gmail.com",    :port      => 587,    :domain    => "domain.com.ar",    :authentication => :plain,    :user_name      => "test@domain.com.ar",    :password       => "passw0rd",    :enable_starttls_auto => true   } actionmailer::base.view_paths= file.dirname(__file__)  class mailer < actionmailer::base    def daily_email     @var = "var"      mail(   :to      => "myemail@gmail.com",             :from    => "test@domain.com.ar",             :subject => "testing mail") |format|                 format.text                 format.html     end   end end  email = mailer.daily_email puts email email.deliver 

file mailer/daily_email.html.erb

<p>this html email</p> <p> , variable <%= @var %> </p> 

file mailer/daily_email.text.erb

this text email  , variable <%= @var %> 

nice question! helped me understand bit more how rails 3 works :)


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -