Advertisement
Guest User

Untitled

a guest
Feb 26th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. class Message
  2. include ActiveAttr::Model
  3. include ActiveModel::Validations
  4.  
  5. attribute :name
  6. attribute :email
  7. attribute :subject
  8. attribute :body
  9. attr_accessible :name, :email, :subject, :body
  10.  
  11. validates_presence_of :name
  12. validates_presence_of :email
  13. validates :email, email_format: { message: "is not looking like a valid email address"}
  14. validates_presence_of :subject
  15. validates_length_of :body, maximum: 500
  16. end
  17.  
  18. class ContactForm < ActionMailer::Base
  19. default from: "myemail@gmail.com"
  20. default to: "myemail@gmail.com"
  21.  
  22. def email_form(message)
  23. @message = message
  24. mail subject: "#{message.subject} #{message.name}"
  25. mail body: "#{message.body}"
  26. end
  27. end
  28.  
  29. config.action_mailer.delivery_method = :smtp
  30. config.action_mailer.perform_deliveries = true
  31. config.action_mailer.smtp_settings = {
  32. :address => "smtp.gmail.com",
  33. :port => 587,
  34. :domain => "mydomain.com",
  35. :user_name => "myemail@gmail.com",
  36. :password => "mypassword",
  37. :authentication => :plain,
  38. :enable_starttls_auto => true
  39. }
  40.  
  41. config.action_mailer.default_url_options = {
  42. :host => "localhost:3000"
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement