Posted By

PhilK on 11/27/09


Tagged

ruby example ActionMailer


Versions (?)

ActionMailer Gmail Example


 / Published in: Ruby
 

Simple example for using ActionMailer with Gmail (or other hosts if you remove the TLS settings).

  1. require "action_mailer"
  2.  
  3. class Notifier < ActionMailer::Base
  4. def email(address)
  5. recipients "[email protected]"
  6. from "[email protected]"
  7. subject "Hello World"
  8. body address
  9. end
  10. end
  11.  
  12. # TLS settings are for gmail, not needed for other mail hosts.
  13. Notifier.delivery_method = :smtp
  14. Notifier.smtp_settings = {
  15. :tls => true,
  16. :enable_starttls_auto => true,
  17. :address => "smtp.gmail.com",
  18. :port => 587,
  19. :domain => "yourdomain.com",
  20. :user_name => "[email protected]",
  21. :password => "12345",
  22. :authentication => :plain
  23. }
  24.  
  25. Notifier.deliver_email("[email protected]")

Report this snippet  

You need to login to post a comment.